.wrap | R Documentation |
This generic and some methods will do whatever is required to prepare an object for
saving to disk (or RAM) via e.g., saveRDS
. Some objects (e.g., terra
's Spat*
)
cannot be saved without first wrapping them. Also, file-backed objects are similar.
.wrap(
obj,
cachePath,
preDigest,
drv = getDrv(getOption("reproducible.drv", NULL)),
conn = getOption("reproducible.conn", NULL),
verbose = getOption("reproducible.verbose"),
outputObjects = NULL,
...
)
## S3 method for class 'list'
.wrap(
obj,
cachePath,
preDigest,
drv = getDrv(getOption("reproducible.drv", NULL)),
conn = getOption("reproducible.conn", NULL),
verbose = getOption("reproducible.verbose"),
outputObjects = NULL,
...
)
## S3 method for class 'environment'
.wrap(
obj,
cachePath,
preDigest,
drv = getDrv(getOption("reproducible.drv", NULL)),
conn = getOption("reproducible.conn", NULL),
verbose = getOption("reproducible.verbose"),
outputObjects = NULL,
...
)
## Default S3 method:
.wrap(
obj,
cachePath,
preDigest,
drv = getDrv(getOption("reproducible.drv", NULL)),
conn = getOption("reproducible.conn", NULL),
verbose = getOption("reproducible.verbose"),
...
)
## Default S3 method:
.unwrap(
obj,
cachePath,
cacheId,
drv = getDrv(getOption("reproducible.drv", NULL)),
conn = getOption("reproducible.conn", NULL),
...
)
.unwrap(
obj,
cachePath,
cacheId,
drv = getDrv(getOption("reproducible.drv", NULL)),
conn = getOption("reproducible.conn", NULL),
...
)
## S3 method for class 'environment'
.unwrap(
obj,
cachePath,
cacheId,
drv = getDrv(getOption("reproducible.drv", NULL)),
conn = getOption("reproducible.conn", NULL),
...
)
## S3 method for class 'list'
.unwrap(
obj,
cachePath,
cacheId,
drv = getDrv(getOption("reproducible.drv", NULL)),
conn = getOption("reproducible.conn", NULL),
...
)
obj |
Any arbitrary R object. |
cachePath |
A repository used for storing cached objects.
This is optional if |
preDigest |
The list of |
drv |
if using a database backend, drv must be an object that inherits from DBIDriver e.g., from package RSQLite, e.g., SQLite |
conn |
an optional DBIConnection object, as returned by dbConnect(). |
verbose |
Numeric, -1 silent (where possible), 0 being very quiet,
1 showing more messaging, 2 being more messaging, etc.
Default is 1. Above 3 will output much more information about the internals of
Caching, which may help diagnose Caching challenges. Can set globally with an
option, e.g., |
outputObjects |
Optional character vector indicating which objects to return. This is only relevant for list, environment (or similar) objects |
... |
Arguments passed to methods; default does not use anything in |
cacheId |
Used strictly for messaging. This should be the cacheId of the object being recovered. |
Returns an object that can be saved to disk e.g., via saveRDS
.
# For SpatExtent
if (requireNamespace("terra")) {
ex <- terra::ext(c(0, 2, 0, 3))
exWrapped <- .wrap(ex)
ex1 <- .unwrap(exWrapped)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.