Re: [R] how to unzip files in R
Depending on what you want to do with that file, there may be no need to uncompress read.table(), e.g., works fine with the compressed version. Benno On Feb 1, 2012, at 2:04 AM, Luke Miller wrote: Try the bzfile() function instead of unz(). You'll find that you're taken to the same help page for both of those functions. ?bzfile 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.2RSQLite_0.10.0 [6] DBI_0.2-5Biobase_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.0tools_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. Benno Pütz Statistical Genetics MPI of Psychiatry Kraepelinstr. 2-10 80804 Munich, Germany T: ++49-(0)89-306 22 222 F: ++49-(0)89-306 22 601 [[alternative HTML version deleted]] __ 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.
Re: [R] how to unzip files in R
Hi Henrik, That is exactly what I was looking for. I worked great. Many thanks. By the way it doesn't seem to be able to do batch mode. I guess I will have to iterate through. But thats ok. John On 1/31/12, Henrik Bengtsson h...@biostat.ucsf.edu wrote: 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.2RSQLite_0.10.0 [6] DBI_0.2-5Biobase_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.0tools_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.
Re: [R] how to unzip files in R
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.
Re: [R] how to unzip files in R
Try the bzfile() function instead of unz(). You'll find that you're taken to the same help page for both of those functions. ?bzfile 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.