解压缩.zip文件

sal*_*hki 18 r

我想在R中解压缩一个文件.我完全不知道该怎么做.

我搜索了一下,我找到了这样的方法:

unzip(zipfile, files = NULL, list = FALSE, overwrite = TRUE,
      junkpaths = FALSE, exdir = ".", unzip = "internal",
      setTimes = FALSE)
Run Code Online (Sandbox Code Playgroud)

但我不知道该怎么办呢.

Des*_*set 25

你可以这样做:

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 
Run Code Online (Sandbox Code Playgroud)

那你也可以用经典的方式在R中定义两条路径:

假设您的zip文件已命名 file.zip

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

exdir定义要将文件解压缩到的目录.如果尚未提供,将创建它.如果未设置exdir,unzip只需将其解压缩到当前工作目录即可.

  • 您可以在Windows中使用正斜杠 (4认同)