rftpsystem-error

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!


Solution

  • 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.