compress: Single-step compression of raw data
Description
Compresses the provided raw data in a single step.
Usage
compress(
data,
level = -1,
method = zlib$DEFLATED,
wbits = zlib$MAX_WBITS,
memLevel = zlib$DEF_MEM_LEVEL,
strategy = zlib$Z_DEFAULT_STRATEGY,
zdict = NULL
)
Value
A raw vector containing the compressed data.
Arguments
- data
Raw data to be compressed.
- level
Compression level, default is -1.
- method
Compression method, default is zlib$DEFLATED
.
- wbits
Window bits, default is zlib$MAX_WBITS
.
- memLevel
Memory level, default is zlib$DEF_MEM_LEVEL
.
- strategy
Compression strategy, default is zlib$Z_DEFAULT_STRATEGY
.
- zdict
Optional predefined compression dictionary as a raw vector.
Details
The compress
function simplifies the compression process by encapsulating
the creation of a compression object, compressing the data, and flushing the buffer
all within a single call. This is particularly useful for scenarios where the user
wants to quickly compress data without dealing with the intricacies of compression
objects and buffer management. The function leverages the compressobj
function
to handle the underlying compression mechanics.
Examples
Run this codecompressed_data <- compress(charToRaw("some data"))
Run the code above in your browser using DataLab