Writes an R object to the cache directory. Uses qs2 for fast
serialization when available, falling back to RDS for general
objects. Small data frames and data.tables are saved as CSV via
data.table::fwrite() for easy inspection.
Usage
WriteCache(
x,
file,
format = c("auto", "qs2", "rds", "csv"),
max_rows = 1000L,
max_cols = 20L,
...
)Arguments
- x
An R object to be cached.
- file
Character string. Path to the cache file (with or without extension). If no extension is given, it is appended automatically.
- format
Character string. Cache format. One of
"auto","qs2","rds", or"csv". When"auto"(default):If
xis a data.frame with at mostmax_rowsrows andmax_colscolumns, CSV format is used.Otherwise,
qs2is preferred when the package is installed, falling back toRDS.
- max_rows
Integer. Maximum number of rows to consider a data.frame "small". Default is
1000L.- max_cols
Integer. Maximum number of columns to consider a data.frame "small". Default is
20L.- ...
Additional arguments (must be empty, checked by
rlang::check_dots_empty0()).
See also
Other cache_config:
CacheSetHere(),
CheckCache(),
ChooseCache(),
LoadCache(),
WriteCacheMeta()