Aliases: memCompress memDecompress
Keywords: file connection
### ** Examples txt <- readLines(file.path(R.home("doc"), "COPYING")) sum(nchar(txt))
[1] 17671
txt.gz <- memCompress(txt, "g") length(txt.gz)
[1] 6837
txt2 <- strsplit(memDecompress(txt.gz, "g", asChar = TRUE), "\n")[[1]] stopifnot(identical(txt, txt2)) txt.bz2 <- memCompress(txt, "b") length(txt.bz2)
[1] 6168
## can auto-detect bzip2: txt3 <- strsplit(memDecompress(txt.bz2, asChar = TRUE), "\n")[[1]] stopifnot(identical(txt, txt3)) ## xz compression is only worthwhile for large objects txt.xz <- memCompress(txt, "x") length(txt.xz)
[1] 6564
txt3 <- strsplit(memDecompress(txt.xz, asChar = TRUE), "\n")[[1]] stopifnot(identical(txt, txt3))