简体   繁体   English

创建 zip 文件:错误运行命令“”的状态为 127

[英]Create zip file: error running command “ ” had status 127

I am trying to create a zip file from multiple files using the zip function in r, but I keep getting this error message: running command '"zip" -r9X "data.zip" "dt1.txt" "dt2.txt" ' had status 127.我正在尝试使用 r 中的zip函数从多个文件创建一个 zip 文件,但我不断收到此错误消息: running command '"zip" -r9X "data.zip" "dt1.txt" "dt2.txt" '状态为 127。

How can I avoid that?我怎样才能避免这种情况?

setwd()
dt1 <- sample(1:100, 10)
dt2 <- sample(100:200, 10)
write(dt1, "dt1.txt")
write(dt2, "dt2.txt")

zip('data.zip', files =c('dt1.txt', 
                         'dt2.txt'))

Here is how I solved this problem on my Windows 7 computer:以下是我在 Windows 7 计算机上解决此问题的方法:

  1. Install Rtools from HERE .这里安装Rtools
  2. Locate the folder that Rtools is installed.找到安装Rtools的文件夹。 In my case it is at C:\\Rtools .就我而言,它位于C:\\Rtools
  3. Add C:\\Rtools\\bin path to the system path.C:\\Rtools\\bin路径添加到系统路径。

Adding C:\\Rtools\\bin to the system path:C:\\Rtools\\bin添加到系统路径:

  1. Go to Control Panel >> System and Security >> System进入Control Panel >> System and Security >> System
  2. Go to Advanced System Settings进入Advanced System Settings
  3. Open Advanced tab打开Advanced选项卡
  4. Click Environmental Variables... button单击Environmental Variables...按钮
  5. Select Path variable and click Edit button选择Path变量并单击Edit按钮
  6. If there is nothing as a "Variable Value" you can simply write C:\\Rtools\\bin .如果没有任何“变量值”,您可以简单地编写C:\\Rtools\\bin If there is already a value, then add ;C:\\Rtools\\bin to the end of it.如果已经存在一个值,则将;C:\\Rtools\\bin到它的末尾。
  7. Click OK, OK...点击确定,确定...
  8. Restart R, it should work.重新启动R,它应该可以工作。

I hope this helps.我希望这有帮助。 I found the solution HERE .我在这里找到了解决方案。

我能够通过删除~/Users/<NAME>/Documents/R/win-library上的写保护来解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM