LazyData
functionality for packages
which do not provide it. It acts as an enhanced substitute for the
base packges require
function.
requireData(package = stop("you must specify a package"), lib.loc = NULL, quietly = TRUE, character.only = FALSE, warn.conflicts = TRUE, reallyQuietly = TRUE, ...)
require
.
reallyQuiet
is TRUE
.
package
argument be treated as a
character string even if not literal?
require
.
Ignored if reallyQuiet
is TRUE
.
package
be loaded using
suppressPackageStartupMessages
? If TRUE
, the default,
this will make the loading
as quietly as possible, but will suppress potentially useful
messages, such as masking information.
TRUE
if the package was successfully attached and FALSE
otherwise.
requireData
, is a
substitute for the base function require
. If the package is
not already on the search path, it attaches it. In addition, if the
package a) has data sets and b) does NOT use the LazyData facility,
then an additonal entry is made on the search path. This is an
unlocked environment initially populated by `promises'
(using delayedAssign
) to load a copy of the data set into
memory if and when it is needed.This is done recursively for all packages attached to the search path via dependencies.
If the package appears on the search path as package:
at
positon p
, then any exposed data set objects appear at postion
p+1
as datasets:
. The package environment is
locked, but the datasets environment is not. If a data set object is
needed at any stage, it is brought silently into memory at position
p+1
on the search path.
Any further call to requireData(
will reinstate the
datasets as promises, thus potentially freeing memory.
The intended effect is to make data sets more conveniently available
to users, to make the use of the data
function largely
unnecessary, and to avoid cluttering the global environment with
copies of passive data set objects.
require
, data
requireData("mgcv") ## we assume has data sets but no LazyLoad
.Search() ## show augmented search path
## > ls("datasets:mgcv")
##[1] "columb" "columb.polys"
Run the code above in your browser using DataLab