compress: In-memory zlib compression of R content

View source: R/compress.R

compressR Documentation

In-memory zlib compression of R content

Description

This uses the standard zlib algorithm/format for compressing the input into a buffer that can be passed to other computations.

This does not use the same algorithm or format that the shell tool compress uses, i.e. LZW (Lempel-Ziv-Welch).

Usage

compress(str, size = nchar(str) * 1.01 + 13, level = integer(3))

Arguments

str

the text to be compressed

size

the size for a working buffer that zlib uses during the compression.

level

the level of compression. This is a number between 0 and 9. 9 means highly compressed, 0 means no compression at all. The trade-off is computational intensity: the greater the compression, the greater the time spent performing the compression.

Value

A “raw” vector containing the compressed contents.

Author(s)

Duncan Temple Lang

References

zlib and bzip2

See Also

uncompress gunzip bunzip2

Examples

 x = "A string to compress"
 g = compress(x)
 uncompress(g) == x

omegahat/Rcompression documentation built on Nov. 29, 2023, 12:45 a.m.