2015-10-18 236 views
10

我想在R中解壓縮文件。我完全不知道該怎麼辦。解壓縮.zip文件

我搜索,我發現它的方法是這樣的:

unzip(zipfile, files = NULL, list = FALSE, overwrite = TRUE, 
     junkpaths = FALSE, exdir = ".", unzip = "internal", 
     setTimes = FALSE) 

,但我不知道我應該怎麼做這個。

+6

看起來像你找到了幫助文件。你讀過它嗎? –

+0

可能dup? http://stackoverflow.com/questions/3053833/using-r-to-download-zipped-data-file-extract-and-import-data – hrbrmstr

+0

@hrbrmstr - 這是一個'unz()'雖然 –

回答

10

你可以做這樣的:

zipF<-file.choose() # lets you choose a file and save its file path in R (at least for windows) 
outDir<-"C:\\Users\\Name\\Documents\\unzipfolder" # Define the folder where the zip file should be unzipped to 
unzip(zipF,exdir=outDir) # unzip your file 

那麼你也可以R中定義兩個路徑的傳統方式:假設你的zip文件

名爲file.zip

zipF<- "C:\\path\\to\\my\\zipfile\\file.zip" 
outDir<-"C:\\Users\\Name\\Documents\\unzipfolder" 
unzip(zipF,exdir=outDir) 

exdir定義將文件提取到的目錄。如果尚不可用,它將被創建。 如果你沒有設置exdirunzip只會將它解壓縮到你當前的工作目錄。

+1

你可以在Windows中使用正斜槓 – rawr