I may be wrong, but I don't think unz() handles bz2 files - only zip files.
See bunzip2() of the R.utils package (which utilizes bzfile connections). /Henrik On Tue, Jan 31, 2012 at 2:34 PM, ql16717 <ql16...@gmail.com> wrote: > Hi, > > I have downloaded a bunch of bz2 files. I wonder if R will be able to > unzip them in a batch mode or even one at a time? > > I was looking at the unz function. But it didn't work well. Say I have > a bz2 file in H:/Temp/65502805_532.pair.bz2. Anyone has any > suggestion? > > thanks > John > >> setwd("H:\\Temp\\") >> getwd() > [1] "H:/Temp" >> fn<-list.files(pattern="bz2", full.names=TRUE) >> fn > [1] "./65502805_532.pair.bz2" >> unz(description=fn, filename="65502805_532.pair", open="r") > Error in unz(description = fn, filename = "65502805_532.pair", open = "r") : > cannot open the connection > In addition: Warning message: > In unz(description = fn, filename = "65502805_532.pair", open = "r") : > cannot open zip file './65502805_532.pair.bz2' > >> sessionInfo() > R version 2.14.0 (2011-10-31) > Platform: i386-pc-mingw32/i386 (32-bit) > > locale: > [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United > States.1252 > [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C > [5] LC_TIME=English_United States.1252 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > [1] pdInfoBuilder_1.18.0 oligo_1.18.1 oligoClasses_1.16.0 > affxparser_1.26.2 RSQLite_0.10.0 > [6] DBI_0.2-5 Biobase_2.12.1 > > loaded via a namespace (and not attached): > [1] affyio_1.22.0 Biostrings_2.22.0 bit_1.1-8 > ff_2.2-4 IRanges_1.12.1 > [6] preprocessCore_1.16.0 splines_2.14.0 tools_2.14.0 > zlibbioc_1.0.0 > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.