compress_chars: Recursively Call 'char_map'/'map2char' on a List

View source: R/compress_chars.R

compress_charsR Documentation

Recursively Call char_map/map2char on a List

Description

These originally internal functions are exported because they are also useful for reducing the size of e.g. a data frame before storing it to disk using saveRDS. This also improves the (de)serialization speed.

Usage

compress_chars(
  l,
  limit = 0L,
  compress_altreps = c("if_allocated", "yes", "no"),
  class = character()
)

uncompress_chars(l, class = character())

Arguments

l

an object, typically a list

limit

the minimum length of a character vector for char_map to be applied

compress_altreps

should a character vector be compressed if it is an ALTREP? The default "if_allocated" only does so if the regular representation was already created. This was chosen as the default because in this case is is the regular representation which would be serialized.

class

additional classes to set on the char_map-objects created by compress_chars. For uncompress_chars, only call map2char on those char_map-objects which additionally inherit from all these classes.

Value

For compress_chars, l, but with character vectors replaced by objects of class char_map. For uncompress_chars, l, but with all char_map-objects, which also inherit from all classes given in class, replaced by the original character vectors.

Windows Support

Fully supported on Windows.

Lifecycle

options:
   alt='[Experimental]'

Note

The object returned by compress_chars might be an invalid S3 object, e.g. if l is a data frame. These functions are intended to be called immediately before and after (de)serializing the object, i.e. compress -> serialize -> store/transfer -> de-serialize -> uncompress.


gfkse/bettermc documentation built on April 23, 2023, 6:51 a.m.