The following R function is modified from Joshua Ulrich's post in stackoverflow. An argument FUN is added for specifying what R function would be employed to process the file handler.
read.zip = function(file, FUN=read.table, ...) {
zipFileInfo = unzip(file, list=TRUE)
if(nrow(zipFileInfo) > 1)
stop("More than one data file inside zip")
else
FUN(unz(file, as.character(zipFileInfo$Name)), ...)
}
Reference:
http://stackoverflow.com/questions/8986818/automate-zip-file-reading-in-r
No comments:
Post a Comment