使用 download.file 同时下载

simultaneous download using download.file

从3.2.1版本开始,officialR文档说支持同时下载。以下是帮助文件中引用的文本:

对方法 "libcurl" 的支持是可选的:使用 capabilities("libcurl") 查看您的构建是否支持它。它提供(非阻塞)访问 https:// 和 ftps:// URLs。支持同时下载,因此 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 会话中止。使用 Windows GUI 的 R,出现以下警告(然后关闭):

R for Windows GUI 前端已停止工作。 "A problem caused the program to stop working correctly. windows will close the program and notify you if a solution is available.".

我正在使用 Windows 8.0。我也 运行 capabilities("libcurl") 并且它给出了以下输出。

libcurl 
   TRUE

根据@thelatemail 的评论:设置 quiet=TRUE 给出了期望的结果(这意味着它是由于进度条):

download.file(url_list,dest_list,method="libcurl",quiet=TRUE)