【发布时间】:2015-09-11 10:31:35
【问题描述】:
从 3.2.1 版本开始,official R 文档说支持同时下载。以下是帮助文件中引用的文本:
对方法“libcurl”的支持是可选的:使用功能(“libcurl”)来查看您的构建是否支持它。它提供对 https:// 和 ftps:// URL 的(非阻塞)访问。支持同时下载,因此 url 和 destfile 可以是相同长度大于 1 的字符向量。对于单个 URL 和 quiet = FALSE,交互式使用中会显示一个进度条。
但是当我尝试从两个不同的网站下载两个文件时,它只下载了一个:
url_list<-c("http://cran.r-project.org/doc/manuals/r-patched/R-exts.html","http://cran.r-project.org/doc/manuals/r-patched/NEWS.pdf")
dest_list<-c("test1.html","test2.pdf")
download.file(url_list,dest_list)
trying URL 'http://cran.r-project.org/doc/manuals/r-patched/R-exts.html'
Content type 'text/html' length 874175 bytes (853 KB)
downloaded 853 KB
Warning messages:
1: In download.file(url_list, dest_list) :
only first element of 'url' argument used
2: In download.file(url_list, dest_list) :
only first element of 'destfile' argument used
然后,我看到我错过了使用参数method="libcurl"
download.file(url_list,dest_list,method="libcurl").
在 RStudio 中运行此命令后:R Studio 发出致命警告,R 会话中止。使用 R for Windows GUI,会出现以下警告(然后关闭):
R for Windows GUI 前端已停止工作。 “一个问题导致程序停止正常工作。windows 将关闭程序并在有解决方案时通知您。”。
我使用的是 Windows 8.0。我还运行了capabilities("libcurl"),它给出了以下输出。
libcurl
TRUE
【问题讨论】:
-
它适用于我在 Linux 上。您可能需要在 Windows 上使用其他东西。
-
我认为它也应该适用于 Windows 。可能是我在这里遗漏了一些东西。
-
是的,对,在 Linux 上。
-
由于无论系统如何,它似乎都在 GUI 上失败,这可能是由于进度条造成的吗?如果设置了
quiet=TRUE会怎样? -
如果还没有,您应该考虑将此作为错误提交。强制程序关闭在基本的“utils”功能中可能不是一件好事。