问题描述
file<-tempfile(fileext=".csv")
download.file(url="ftp://pubftp.spp.org/Markets/DA/LMP_By_SETTLEMENT_LOC/2014/03/28/DA-LMP-SL-201403280100.csv",destfile=file,mode="wb")
这适用于 R(我不知道该怎么称呼它).但是在 RStudio 中它会挂起几分钟,然后我得到以下信息
This works in R proper (I'm not sure what to call it). However in RStudio it hangs for several minutes and then I get the following
trying URL 'ftp://pubftp.spp.org/Markets/RTBM/LMP_By_SETTLEMENT_LOC/2014/03/25/11/RTBM-LMP-SL-201403251015.csv'
using Synchronous WinInet calls
Error in download.file(url = "ftp://pubftp.spp.org/Markets/RTBM/LMP_By_SETTLEMENT_LOC/2014/03/25/11/RTBM-LMP-SL-201403251015.csv", :
cannot open URL 'ftp://pubftp.spp.org/Markets/RTBM/LMP_By_SETTLEMENT_LOC/2014/03/25/11/RTBM-LMP-SL-201403251015.csv'
In addition: Warning message:
In download.file(url = "ftp://pubftp.spp.org/Markets/RTBM/LMP_By_SETTLEMENT_LOC/2014/03/25/11/RTBM-LMP-SL-201403251015.csv", :
InternetOpenUrl failed: ''
这是一个小文件,所以它不应该超时,但我真的不知道问题是什么.
It is a small file so it shouldn't time out but I really don't know what the problem is.
推荐答案
我找到了两个解决方案.
I found two solutions.
1) 转到工具">全局选项">包",然后取消选择使用 Internet Explorer 库/代理进行 HTTP".
1) Go to Tools > Global Options > Packages, and unselect "Use Internet Explorer library/proxy for HTTP".
2) 这对另一个用户有效,但对我无效:setInternet2(use=FALSE)
2) This worked for another user, but not for me: setInternet2(use=FALSE)
注意:当我在 RGUI 中输入 setInternet2(use=TRUE),然后尝试下载时,它给出了使用同步 WinInet 调用"消息并挂起;但随后 Windows 防火墙弹出,当我允许 RGUI 通过它时,下载开始.
Note: when in RGUI I entered setInternet2(use=TRUE), then tried the download, it gave the "using Synchronous WinInet calls" messages and hung; but then Windows Firewall popped up, and when I allowed RGUI through it, the download began.
这篇关于Download.file 在 RStudio 中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!