memCompress
In-memory Compression and Decompression

Description

Performs an in-memory compression or decompression of a raw vector or a character string.

Usage

memCompress(from, type = c("gzip", "bzip2", "xz", "none"))
memDecompress(from, type = c("unknown", "gzip", "bzip2", "xz", "none"), 
              asChar = FALSE)

Arguments

from a raw vector or a character string to be compressed or decompressed. If memCompress is given a string vector of length greater and one, the strings are concatenated with a carriage return between them before they are compressed.
type a character string. Indicates the compression type to be compressed or decompressed.

In memDecompress, if type is specified as "unknown", and if it is "bzip2" or "xz", the type is detected. Otherwise, memDecompress generates a warning and "none" is used. (The type "none" indicates that no compression or decompression is done.)

asChar a logical value.
  • If TRUE, from is decompressed to a character vector.
  • If FALSE (the default), from is decompressed to a raw vector.
Value
returns a raw vector or a character string.
See Also
gzfile, bzfile, xzfile, gzcon.
Examples
x <- memCompress("This is a test", "g")
memDecompress(x, "g", asChar = TRUE)

## can infer compression type for bzip2 x <- memCompress("This is a test", "bz") memDecompress(x, asChar = TRUE)

Package base version 6.1.1-7
Package Index