【发布时间】:2021-12-21 06:42:02
【问题描述】:
我正在尝试从 url 下载文件。如果我手动下载并解压缩它可以正常工作,但是,使用 download.file zip 已损坏。我想知道这是否与手动指定文件名有关。为什么在使用 download.file 函数时需要这样做?难道不能简单地指定一个url和文件夹,然后下载服务器上命名的文件吗?
##using R
##download url
url <- 'https://www.eea.europa.eu/data-and-maps/data/eea-reference-grids-2/gis-files/denmark-shapefile/at_download/file'
download.file(url, destfile ='Denmark_shapefile.zip')
unzip(zipfile = 'Denmark_shapefile.zip', exdir = '.')
文件损坏导致解压失败
【问题讨论】:
-
你可以使用
temp <- tempfile(); download.file(url, temp) -
它用这个下载,但我找不到在哪里,它不是工作目录。有没有办法指定目录而不指定文件名?
标签: r downloadfile