'How to open a gzip file in R?
unzip("fasta.gz")
Warning message: In unzip("fasta.gz") : error 1 in extracting from zip file
I am trying to unzip a zip file but it is not working what am I doing wrong?
Solution 1:[1]
Would something like this work?
# Input:
# file_name: the name of the file to unzip
#
# Output:
# file_name: the name of the unzipped file
#
# Usage:
# file_name <- unzip_file(file_name)
#
unzip_file <- function(file_name) {
file_name <- gzfile(file_name)
file_name <- unzip(file_name)
file_name <- gzfile(file_name)
file_name
}
Solution 2:[2]
No, you are trying to decompress a gzip file, not a zip file. Those are two different things. unzip is for zip files. Use gunzip() or gzfile() for gzip files.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | PCDSandwichMan |
| Solution 2 | Mark Adler |
