Load complete package.
load_all loads a package. It roughly simulates what happens
when a package is installed and loaded with
load_all(pkg = ".", reset = TRUE, recompile = FALSE, export_all = TRUE, quiet = FALSE, create = NA)
- package description, can be path or package name. See
as.packagefor more information.
- clear package environment and reset file cache before loading
any pieces of the package. This is equivalent to running
unloadand is the default. Use
reset = FALSEmay be faster for large code b
- force a recompile of DLL from source code, if present.
This is equivalent to running
TRUE(the default), export all objects. If
FALSE, export only the objects that are listed as exports in the NAMESPACE file.
TRUEsuppresses output from this function.
- only relevant if a package structure does not exist yet: if
TRUE, create a package structure; if
NA, ask the user (in interactive mode only)
- Loads all data files in
load_datafor more details.
- Sources all R files in the R directory, storing results in
environment that behaves like a regular package namespace. See
load_codefor more details.
- Compiles any C, C++, or Fortran code in the
src/directory and connects the generated DLL into R. See
compile_dllfor more details.
- If you use
testthat, will load all test helpers so you can access them interactively.
.onUnload()functions at the correct times.
The namespace environment
, is a child of
the imports environment, which has the name attribute
imports:pkgname. It is in turn is a child of
, which is a child of the global environment.
(There is also a copy of the base namespace that is a child of the empty
The package environment
is an ancestor of the
global environment. Normally when loading a package, the objects
listed as exports in the NAMESPACE file are copied from the namespace
to the package environment. However,
load_all by default will
copy all objects (not just the ones listed as exports) to the package
environment. This is useful during development because it makes all
objects easy to access.
To export only the objects listed as exports, use
export_all=FALSE. This more closely simulates behavior when
loading an installed package with
library, and can be
useful for checking for missing exports.
load_all also inserts shim functions into the imports environment
of the laded package. It presently adds a replacement version of
system.file which returns different paths from
base::system.file. This is needed because installed and uninstalled
package sources have different directory structures. Note that this is not
a perfect replacement for
# Load the package in the current directory load_all("./") # Running again loads changed files load_all("./") # With reset=TRUE, unload and reload the package for a clean start load_all("./", TRUE) # With export_all=FALSE, only objects listed as exports in NAMESPACE # are exported load_all("./", export_all = FALSE)