Hello,
Can someone help me with unzipping a .gz file. I used:
readLines(gzfile('/home/file.gz'))
I also found that I could use gunzip, but after trying to install it, it
says:
"package ?gunzip? is not available (for R version 2.15.1)"
Thanks,
Alexandra
[[alternative HTML version deleted]]
Alexandra, Although you may not have control over the installation of R,
2.15.1 is very old and should be upgraded--the current is 3.1.2
Clint Bowman INTERNET: clint at ecy.wa.gov
Air Quality Modeler INTERNET: clint at math.utah.edu
Department of Ecology VOICE: (360) 407-6815
PO Box 47600 FAX: (360) 407-7534
Olympia, WA 98504-7600
USPS: PO Box 47600, Olympia, WA 98504-7600
Parcels: 300 Desmond Drive, Lacey, WA 98503-1274
On Tue, 10 Feb 2015, Alexandra Catena wrote:
> Hello,
>
> Can someone help me with unzipping a .gz file. I used:
>
> readLines(gzfile('/home/file.gz'))
>
>
> I also found that I could use gunzip, but after trying to install it, it
> says:
>
> "package ?gunzip? is not available (for R version 2.15.1)"
>
>
> Thanks,
> Alexandra
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>
readLines (as well as other I/O routines) handles gzip files transparently, you
should be able to simply use
readLines('/home/file.gz?)
Benno
On 10 Feb 2015, at 22:45 , Alexandra Catena <amc5981 at gmail.com> wrote:
> Hello,
>
> Can someone help me with unzipping a .gz file. I used:
>
> readLines(gzfile('/home/file.gz'))
>
>
> I also found that I could use gunzip, but after trying to install it, it
> says:
>
> "package ?gunzip? is not available (for R version 2.15.1)"
>
>
> Thanks,
> Alexandra
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
Not clear if you need to:
1. decompress /home/file.gz, or
2. read the content of /home/file.gz into R.
For (1) you can use `gunzip` at the command line, or
gunzip("/home/file.gz") of the R.utils package. For (2), as already
mentioned, R does a good job of reading gzip'ed files "as is". It
may
even be that you don't have to use gzfile().
DEMO:
# Create gzip'ed file> cat(file="foo.txt", "Hello world!\n")
> R.utils::gzip("foo.txt")
# Read directly from it> readLines("foo.txt.gz")
[1] "Hello world!"
# Decompress it> R.utils::gunzip("foo.txt.gz")
> readLines("foo.txt")
[1] "Hello world!"
/Henrik
On Tue, Feb 10, 2015 at 1:45 PM, Alexandra Catena <amc5981 at gmail.com>
wrote:> Hello,
>
> Can someone help me with unzipping a .gz file. I used:
>
> readLines(gzfile('/home/file.gz'))
>
>
> I also found that I could use gunzip, but after trying to install it, it
> says:
>
> "package ?gunzip? is not available (for R version 2.15.1)"
>
>
> Thanks,
> Alexandra
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.