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")
请发表评论