操作系统:Win 7 64位RStudio版本1.1.463
根据Getting and Cleaning Data课程,我尝试使用method = curl下载csv文件:
fileUrl <- "https://data.baltimorecity.gov/api/views/dz54-2aru/rows.csv?accessType=DOWNLOAD"
download.file(fileUrl, destfile = "./cameras.csv", method = "curl")
download.file中的错误(fileUrl,destfile =“./ camera.sv”,method =“curl”):'curl'调用具有非零退出状态
但是,method = libcurl
成功下载:
download.file(fileUrl, destfile = "./cameras.csv", method = "libcurl")
尝试URL'https://data.baltimorecity.gov/api/views/dz54-2aru/rows.csv?accessType=DOWNLOAD'下载了9443个字节
从* http *** s **变为http分别为curl
和libcurl
产生了完全相同的结果。
无论如何根据课程通过method = curl
进行下载工作?
谢谢
从?download.file
可以看到:
对于方法“wget”和“curl”,系统调用由方法给出的工具,并且相应的程序必须安装在您的系统上并且位于可执行文件的搜索路径中。它们将阻止R进程上的所有其他活动,直到它们完成:这可能会使GUI无响应。
因此,您应该安装curl
first。请参阅此How do I install and use curl on Windows?以了解具体方法。最好!
我相信这里有一些问题:遵循@JonnyCrunch引用的链接中的步骤
a)为Windows重新安装Git;
b)将C:\ Program Files \ Git \ mingw64 \ bin \添加到'PATH'变量;
c)禁用在RStudio中使用Internet Explorer库/代理进行HTTP:工具>选项>包
d)尝试下面的“e)”步骤,并根据卡巴斯基反病毒提示将data.baltimorecity.gov网站添加到排除项中;
e)然后在RStudio中:
options(download.file.method = "curl")
download.file(fileUrl, destfile="./data/cameras.csv")
成功!
谢谢