Download.file函数似乎不起作用

时间:2015-06-10 13:18:02

标签: r

我想将一些.csv在线数据提取到R.所以我这样做(我已经创建了一个名为"数据")

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

但它给出了我的跟随错误:

 Warning messages:
 1: running command 'curl  "https://data.baltimorecity.gov/api/views/dz54-     2aru/rows.csv?accessType=DOWNLOAD"  -o "./data/cameras.csv"' had status    127 
 2: In download.file(fileUrl, destfile = "./data/cameras.csv", method  = "curl") download had nonzero exit status

如果我删除了method= "curl"我得到了

Error in download.file(fileUrl, destfile = "./data/cameras.csv") : 
unsupported URL scheme

关于出了什么问题的任何想法?

2 个答案:

答案 0 :(得分:1)

我也有这个问题。将method =“curl”更改为method =“auto”对我有用。

答案 1 :(得分:0)

注意http而不是https,下面的代码将起作用:

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