An R package for stashing objects in lazy load databases, analogous to lazy loaded packages.
This uses the archivist
package for the back end, using the .rda
files or raster-based files. The lazy mechanism is at loading time only, creating a promise to evaluate the loadFromLocalRepo()
function when it is needed.
The basic work flow is:
decide on a folder for the database, and set it using lazyDir()
save objects to a lazyR database using lazySave(obj)
lazySave(obj, tags=c("maps", "USA"))
list the contents of the lazyR database with lazyLs()
lazyLoad2(tag="maps")
lazyRm("objName")
or lazyRm(lazyLs("tagname"))
An alternative workflow is to use the %<%
(assignCache
) operator, which will automatically cache the object with its assigned object name. Caching, like with the archivist package, will first do a hash of the arguments in the function, compare with the hashed value of the objects in the database, and return the cached object, if the hash values are the same.
Example:
decide on a folder for the database, and set it using
lazyDir(tempdir(), create=TRUE)
assign objects via %<%
. See help(cacheAssign)
a %<% seq(1,10,1)
lazyLs()
will list all objects in the databaselazyLs(tagType="all")
will list the full archivist
data.frame
with columns: md5Hash
, tag
, dateCreated
.archivist
packageThe lazyDir
argument in the lazyR
package is exactly the same as a repository in archivist.
Thus, all archivist functions work with the lazyR
package. Simply use lazyDir and RepoDir interchangeably.
Notes:
Some tags are done automatically
is(obj)
, prefixed by class:
in the tagsobjectName:
Objects of class Raster*
are special because of their "sometimes on disk" nature.
lazySave(..., copyRasterFile=TRUE)
to save it. This is also required to ensure portability of a lazyR
database.Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.