我尝试下载并使用R.提取zip文件每当我这样做,我得到错误信息[R exdir不存在错误
错误的解压(温度,列表= TRUE):' exdir”不存在
我使用基于堆栈溢出问题Using R to download zipped data file, extract, and import data
举一个简单的例子代码:
# Create a temporary file
temp <- tempfile()
# Download ZIP archive into temporary file
download.file("http://cran.r-project.org/bin/windows/contrib/r-release/ggmap_2.2.zip",temp)
# ZIP is downloaded successfully:
# trying URL 'http://cran.r-project.org/bin/windows/contrib/r-release/ggmap_2.2.zip'
# Content type 'application/zip' length 4533970 bytes (4.3 Mb)
# opened URL
# downloaded 4.3 Mb
# Try to do something with the downloaded file
unzip(temp,list=TRUE)
# Error in unzip(temp, list = TRUE) : 'exdir' does not exist
我试过到目前为止:
- 手动访问临时文件,并与7zip的解压缩它:能做到这一点没有问题,文件是存在的并且可以访问。
- 将临时目录更改为c:\ temp。再次,文件被成功下载,我可以访问它并使用7zip解压缩,但是R在尝试访问它时会抛出exdir错误消息。
[R版本2.15.2
R-Studio版本0.97.306
编辑:代码工作,如果我使用unz代替unzip,但我一直无法弄清楚为什么一个人工作,另一个不工作。从CRAN指导:
- UNZ读取头(只)zip文件中单个文件...
- 解压缩从提取的文件或列出一个zip压缩包
您的代码适用于我,没有错误。 – 2013-03-05 14:33:37
我刚刚编辑过这个问题,unz似乎对我很好,但不能解压缩。 – Tumbledown 2013-03-05 14:36:55
只是为了确认,您是否有权限在您的临时目录中写入,并且您有足够的空间?如果同样的东西适用于经典的R(不是来自Rstudio),也可以尝试,有时候我也遇到过类似Eclipse/StatET的类似问题。 – 2013-03-05 14:43:48