简体   繁体   中英

Why do I get a system status error of 127 when I run wget in R?

I am trying to run a script to download some weather data from a NOAA ftp site. When I attempt to run the following command:

system("wget ftp://ftp.ncdc.noaa.gov/pub/data/noaa/2016/999999-54856-2016.gz") 

it returns status 127, which as I understand simply means the command will not run. This link on the other hand, seems to be working well and downloads the zip folder when I ran it in the browser. I read online about adding the path 'C:\\Rtools\\bin' from this link: Create zip file: error running command " " had status 127 but that doesn't seem to work either. I'm wondering if this might be a permissions issue or other security setting preventing me from invoking system commands. Any ideas? Thanks!

You're using Windows. wget is a Unix/Linux program. You can just call download.file to download from within R:

download.file("ftp://ftp.ncdc.noaa.gov/pub/data/noaa/2016/999999-54856-2016.gz",
              "999999-54856-2016.gz", mode="wb")

The mode="wb" is important for downloading binary files on Windows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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