simultaneous download using download.file
Since the version 3.2.1, the official R document says that there is support for simultaneous downloads. Following is the quoted text from help file:
Support for method "libcurl" is optional: use capabilities("libcurl") to see if it is supported on your build. It provides (non-blocking) access to https:// and ftps:// URLs. There is support for simultaneous downloads, so url and destfile can be character vectors of the same length greater than one. For a single URL and quiet = FALSE there a progress bar is shown in interactive use.
But when I tried to download two files from two different websites, it downloaded only one:
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
Then, I saw that I missed using an argument method="libcurl"
download.file(url_list,dest_list,method="libcurl").
Once I run this command in RStudio: R Studio gives fatal warning and R session gets aborted. With the R for Windows GUI, the following warning occurs (and then shut down):
R for Windows GUI front-end has stopped working. "A problem caused the program to stop working correctly. windows will close the program and notify you if a solution is available.".
I am using Windows 8.0. I also ran capabilities("libcurl")
and it gives the following output.
libcurl
TRUE
根据@thelatemail的评论:设置quiet=TRUE
会给出所需的结果(这意味着它是由于进度条导致的):
download.file(url_list,dest_list,method="libcurl",quiet=TRUE)
链接地址: http://www.djcxy.com/p/27216.html
上一篇: 数字列显示十六进制字符
下一篇: 使用download.file同时下载