日常生活中有文件的链接,这时候需要保存到本地,可以直接下载,当然也可以用download.file()
函数直接保存到本地。
直接来看下操作:
url <- "https://www.stats.govt.nz/assets/Uploads/Annual-enterprise-survey/Annual-enterprise-survey-2020-financial-year-provisional/Download-data/annual-enterprise-survey-2020-financial-year-provisional-csv.csv"
destfile <- "files/output.csv"
download.file(url,destfile)
- url:文件的来源,英文解释:a
character
string (or longer vector e.g., for thelibcurl
method) naming the URL of a resource to be downloaded. - destfile:要保存的目标位置,a character string (or vector, see the url argument) with the file path where the downloaded file is to be saved. Tilde-expansion is performed.
下载完成后就可以在目标路径看到output.csv
文件了。
参考链接:
R Documentation:Download File from the Internet
网友评论