loadModule
will be included in the source
code for a package to load modules and optionally expose objects from
them. The actual extraction of the module takes place at load time.
loadModule(module, what = , loadNow, env =)
loadModule
.
The special value TRUE
says to load all the objects in the
module that have syntactically standard R names (which all objects
in a module will normally have).
Otherwise, if supplied this should be a character vector, the elements being objects defined in the module. The vector can have a names attribute, in which case the non-empty names will be used to rename the objects; otherwise, the name of the object in the package namespace will be the same as the name in the C++ module.
The value of loadNow
will be set by checking the module's
status. At package installation time, the module cannot be started,
in which case a load action (see setLoadAction
) is
scheduled to do the actual module load.
The value of env
will default to the package's namespace.
setRcppClass()
, which does the necessary
module loading for you.When the module can be started (at namespace load time), the function
Module()
returns an environment with a description of
the module's contents. Function loadModule()
saves this as a
metadata object in the package namespace. Therefore multiple calls to
loadModule()
are an efficient way to extract different objects
from the module.
Requesting an object that does not exist in the module produces a warning.
Since assignments from the call cannot take place until namespace
loading time, any computations using the objects must also be
postponed until this time. Use load actions
(setLoadAction
) and make sure that the load action is
specified after the call to loadModule()
.
setRcppClass()
to avoid the explicit call.loadRcppModules()
for a (deprecated) shotgun procedure to load all
modules.
## Not run:
# loadModule("yada", TRUE) # load all the objects from module "yada"
# ## End(Not run)
Run the code above in your browser using DataLab