我正在运行一个脚本,其中包含在代码中引用的输入参数,以自动创建目录,下载文件和untar
文件。我可以使用unzip
,但是我要分析的这个特定文件是.tar.gz
。我手动解压缩,它是tar.gz,解压缩到.tar文件。这会是问题吗?
Full error: Error in untar2(tarfile, files, list, exdir) : unsupported entry type ‘’
运行Windows 10,64位,R设置为:[Default] [64-bit] C:\Program Files\R\R-3.2.2
脚本注意到找到了一个解决方案(问题,第28-31行),但我并不理解它。
我在计算机上安装了7-zip,重新启动,当然重启R:
`#DOWNLOADING AND UNZIPPING TAR FILE
#load required packages.
#If there is a load package error, use install.packages("[package]")
library(dplyr)
library(lubridate)
library(XML) # HTML processing
options(stringsAsFactors = FALSE)
#Set directory locations, data file and fetch data file from internet
#enter full url including file name between ' ' marks
mainDir<-"C:/R/BEES/"
subDir<-"C:/R/BEES/Killers"
Fetch<-'http://dds.cr.usgs.gov/pub/data/nationalatlas/afrbeep020_nt00218.tar.gz'
ArchFile<-basename(Fetch)
download.file<-(ArchFile)
#Check for file directories and create if directory if it doesn't exist
if(!file.exists(mainDir)){dir.create(mainDir)}
if(!file.exists(subDir)){dir.create(subDir)}
#set the working directory
setwd(file.path(subDir))
#check if file exists and download if it doesn't exist.
if(!file.exists(ArchFile))
{download.file (url=Fetch,destfile=ArchFile,method='auto')}
#unpack and view file list
untar(path.expand(ArchFile),list=TRUE,exdir=subDir,compressed="gzip")
list.files(subDir)
#Error: Error in untar2(tarfile, files, list, exdir) :
# unsupported entry type ‘’
#Need solution to use tar/untar app
#instructions here: https://stevemosher.wordpress.com/step-10-build/`
感谢反馈 - 我一直潜伏在StackOverflow上一段时间以使用其他人的解决方案。