encode_source {qs} | R Documentation |
Encode and compress a file or string
Description
A helper function for encoding and compressing a file or string to ASCII using base91_encode()
and qserialize()
with the highest compression level.
Usage
encode_source(x = NULL, file = NULL, width = 120)
Arguments
x |
The object to encode (if |
file |
The file to encode (if |
width |
The output will be broken up into individual strings, with |
Details
The encode_source()
and decode_source()
functions are useful for storing small amounts of data or text inline to a .R or .Rmd file.
Value
A character vector in base91 representing the compressed original file or object.
Examples
set.seed(1); data <- sample(500)
result <- encode_source(data)
# Note: the result string is not guaranteed to be consistent between qs or zstd versions
# but will always properly decode regardless
print(result)
result <- decode_source(result) # [1] 1 2 3 4 5 6 7 8 9 10
[Package qs version 0.26.3 Index]