我试图进入每个子目录并解压缩单个.tar文件,然后 将未压缩的数据放入包含.tar文件的相同子目录中。您能帮忙解决此循环吗,我不明白为什么这不起作用?
这是输出错误:
Error in gzfile(path.expand(tarfile), "rb") : cannot open the connection
In addition: Warning message:
In gzfile(path.expand(tarfile), "rb") :
cannot open compressed file './GSE20292 / GSE20292_RAW.tar', probable reason 'No such file or directory'
这是我尝试过的:
# get into the parent directory
setwd("filepath")
# loop through the sub directories (use [-1] to lop off the current directory: ".")
for (dir in list.dirs()[-1]) {
# get into the sub directory
#setwd(dir)
# do the do
temp <- list.files(dir, pattern="*.tar")
untar(paste(dir, "/", temp), exdir = dir)
# pop back up to the parent directory
setwd("../")
};