Description Usage Arguments Details Note See Also Examples
MakeObj
automatically generates an R object using the provided
expression and saves the associated RDS file, or skips these two operations
and loads the previously saved RDS file when it is available, or even avoids
to do anything when the object is already defined in its parent environment.
The automation performed by MakeObj
can be controlled by optional
arguments and their corresponding global options which are accessible
via the LittleThumb function (see the details section).
1 |
... |
at least an R symbol and an expression defining the corresponding R object. The symbol must be provided in first position and the expression in last position, both as unnamed arguments. |
The MakeObj
function requires at least two arguments: an R symbol
in the first position and an R expression in the last position,
both being provided as unnamed arguments.
When evaluated, the provided expression must define the value
of the R object to be automatically saved or loaded.
For instance, the following line would automatically make/save/load
an integer vector named x
and containing values from 1 to 10:
MakeObj(x, { x <- 1:10 })
In addition, the following named arguments can be used in between the symbol and expression arguments (see LittleThumb):
path
, relative
, embedded
, parent
,
makedir
, reload
, rebuild
, cleanup
,
and messages
MkObj can be used as a short alias of function MakeObj
.
LittleThumb, DeleteObj
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 1. Configure global options --------------------------------------------------
# Here we choose the default location for automatically saved RDS files
LittleThumb(rootpath = "AutoSaved")
# 2. Define persistent R objects -----------------------------------------------
MakeObj(xyz, {
# Here we compute the value of the object
xyz <- 0
})
# 3. Do anything with defined R objects ----------------------------------------
print(xyz)
# Cleanup ======================================================================
DeleteObj(xyz)
unlink("AutoSaved", recursive = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.