Modules are loaded in an isolated environment which is returned, and
optionally attached to the object search path of the current scope (if
argument attach
is TRUE
).
attach
defaults to FALSE
. However, in interactive code it is
often helpful to attach packages by default. Therefore, in interactive code
invoked directly from the terminal only (i.e. not within modules),
attach
defaults to the value of options('import.attach')
, which
can be set to TRUE
or FALSE
depending on the user<U+2019>s preference.
attach_operators
causes operators to be attached by default,
because operators can only be invoked in R if they re found in the search
path. Not attaching them therefore drastically limits a module<U+2019>s usefulness.
doc
loads the module<U+2019>s documentation, specified as roxygen comments.
It defaults to TRUE
in interactive mode and to FALSE
otherwise.
Modules are searched in the module search path options('import.path')
.
This is a vector of paths to consider, from the highest to the lowest
priority. The current directory is always considered last. That is,
if a file a.r
exists both in the current directory and in a module
search path, the local file ./a.r
will not be loaded, unless the
import is explicitly specified as import('./a')
.
Module names can be fully qualified to refer to nested paths. See
Examples
.
Module source code files are assumed to be encoded in UTF-8 without BOM.
Ensure that this is the case when using an extended character set.
pkg = import_package('pkg')
imports a package and treats it much as if
it were a module, making package contents available in the pkg
variable.