compress | R Documentation |
Compress or decompress using gzip, bzip2, or xz compression.
compress(
file,
ext = c("gz", "bz2", "xz", "zip"),
remove = FALSE,
overwrite = FALSE
)
decompress(file, remove = FALSE, overwrite = FALSE)
file |
|
ext |
Supported formats:
|
remove |
|
overwrite |
|
For ZIP files, refer to zip
and unzip
in the utils package.
Invisible character(1)
.
File path.
Updated 2023-09-21.
help("connections")
R.utils::compressFile()
, R.utils::decompressFile()
.
utils::zip()
, utils::unzip()
.
utils::tar()
, utils::untar()
.
memCompress()
, memDecompress()
.
## Create an example text file.
text <- c("hello", "world")
file <- "test.txt"
writeLines(text = text, con = file)
readLines(con = file)
## Apply gzip compression.
gzfile <- compress(
file = file,
ext = "gz",
remove = TRUE,
overwrite = TRUE
)
print(gzfile)
readLines(con = gzfile)
## When `remove = TRUE`, the original input file will be removed.
file.exists(file)
## Decompress the gzipped file.
file <- decompress(
file = gzfile,
remove = TRUE,
overwrite = TRUE
)
print(file)
## Clean up.
unlink2(file)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.