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