15

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.

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'))
  • 1
    It may be worth noting that status 127 means that the command was not found (the zip command in this case). – Johannes Ranke Feb 24 '17 at 14:28
23

Here is how I solved this problem on my Windows 7 computer:

  1. Install Rtools from HERE.
  2. Locate the folder that Rtools is installed. In my case it is at C:\Rtools.
  3. Add C:\Rtools\bin path to the system path.

Adding C:\Rtools\bin to the system path:

  1. Go to Control Panel >> System and Security >> System
  2. Go to Advanced System Settings
  3. Open Advanced tab
  4. Click Environmental Variables... button
  5. Select Path variable and click Edit button
  6. If there is nothing as a "Variable Value" you can simply write C:\Rtools\bin. If there is already a value, then add ;C:\Rtools\bin to the end of it.
  7. Click OK, OK...
  8. Restart R, it should work.

I hope this helps. I found the solution HERE.

| improve this answer | |
  • not working for me, running Windows... I still get "status 127" when trying to run system("SET PATH") – MichaelChirico Feb 26 '16 at 16:38
  • 1
    Had the same issue, but in my case I needed to add the following to the system path: C:\RBuildTools\3.3\bin;C:\RBuildTools\3.3\gcc-4.6.3\bin – phiver Apr 3 '16 at 8:25
  • 1
    it looks like Rtools now sets the system path when installing Rtools.exe (at least on Windows) – SprengMeister Apr 20 '16 at 15:49
  • This did not work for me -- added both the paths mentioned by @phiver & a Sys.getenv("PATH") confirms that the paths were added to the PATH variable. – tchakravarty Nov 4 '16 at 15:35
2

I was able to solve the problem by removing the write-protection on ~/Users/<NAME>/Documents/R/win-library.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.