Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

download.file() in R has non zero exit status

Tags:

r

download

I am trying to download a file in R 3.0.1 (Windows 7):

    fileUrl <- "https://data.baltimorecity.gov/api/views/dz54-2aru/rows.csv?accessType=DOWNLOAD"
    download.file(fileUrl, destfile="./data/cameras.csv", method="curl")

I checked both the url and my internet connection and they seem to be working just fine. However, I get this message:

    Warning message:  
    In download.file(fileUrl, destfile = "./data/cameras.csv", method = "curl") : 
    download had nonzero exit status

Can't find any help online, anybody knows how to fix this?

like image 647
Renne007 Avatar asked Jun 25 '13 14:06

Renne007


People also ask

What does non zero exit status mean?

A non-zero exit status indicates failure. This seemingly counter-intuitive scheme is used so there is one well-defined way to indicate success and a variety of ways to indicate various failure modes. When a command terminates on a fatal signal whose number is N , Bash uses the value 128+ N as the exit status.


2 Answers

The answer by @dickoa probably works, but I think the major issue is that you are using https unnecessarily. I think this works:

# Note the http instead of https
file<-'http://data.baltimorecity.gov/api/views/dz54-2aru/rows.csv?accessType=DOWNLOAD'
read.csv(file)
like image 96
nograpes Avatar answered Sep 27 '22 23:09

nograpes


Still don't understand why removing method = "curl" don't solve the problem.

Another solution is install the downloader package which wrap download.file and make the download process easier and cross-platform (one function with same paramters for all OS)

install.packages("downloader")
fileUrl <- "https://data.baltimorecity.gov/api/views/dz54-2aru
            /rows.csv?accessType=DOWNLOAD"

require(downloader)
download(fileUrl, "data/cameras.csv", mode = "wb")

Hope that it will work this time

like image 29
dickoa Avatar answered Sep 27 '22 22:09

dickoa