我嘗試下載並使用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