R語言下載函數download.file()


download.file()函數

download.file(url,destfile,method,quiet=FALSE,mode="w",cacheOK=TRUE,extra=getOption("download.file.extra"))
    url:字符串,必須http://,https://,ftp://,file://開頭
    destfile:下載文件的保存地址,默認工作目錄,file為保存文件名
    method:提供"internal","wget","curl","lynx","libcurl","wininet".windows上通常internal就能解決大多數的問題,少數搞不定的如Cygwin,gnuwin32用"wget",windows二進制文件用"curl".method對於Mac用戶來說是都要設置的."lynx"主要針對historical interest
    quiet:TRUE-禁止狀態消息,顯示進度條
    mode:寫入文件模式,只能在method="internal"時使用,"w"/"wb"(binary)/"a"(append)/"ab"
    cacheOK:是否接受服務器端的緩存值,對http://,https://使用.FALSE-嘗試從站點獲取副本,而不是從中間緩存中獲取

例子:

 download.file("http://github.com/mgimond/Spatial/raw/master/Data/Income_schooling.zip",
               destfile = "Income_schooling.zip" , mode='wb')
 unzip("Income_schooling.zip", exdir = ".")
 file.remove("Income_schooling.zip")


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM