Functions to load and unload name spaces.
attachNamespace(ns, pos = 2L, depends = NULL, exclude, include.only)
loadNamespace(package, lib.loc = NULL,
keep.source = getOption("keep.source.pkgs"),
partial = FALSE, versionCheck = NULL,
keep.parse.data = getOption("keep.parse.data.pkgs"))
requireNamespace(package, ..., quietly = FALSE)
loadedNamespaces()
unloadNamespace(ns)
isNamespaceLoaded(name)
| Parameter | Description |
|---|---|
ns |
string or name space object. |
pos |
integer specifying position to attach. |
depends |
NULL or a character vector of dependencies to be recorded in object .Depends in the package. |
package |
string naming the package/name space to load. |
lib.loc |
character vector specifying library search path. |
keep.source |
Now ignored except during package installation. |
keep.parse.data |
Ignored except during package installation. |
partial |
logical; if true, stop just after loading code. |
versionCheck |
NULL or a version specification (a list with components op and version). |
quietly |
logical: should progress and error messages be suppressed? |
name |
string or ‘name’, see as.symbol, of a package, e.g., "stats". |
exclude, include.only |
character vectors; see library. |
… |
further arguments to be passed to loadNamespace. |
# NOT RUN {
(lns <- loadedNamespaces())
statL <- isNamespaceLoaded("stats")
# }
# NOT RUN {
<!-- % checks work also when it is *not* loaded -->
# }
# NOT RUN {
stopifnot( identical(statL, "stats" %in% lns) )
## The string "foo" and the symbol 'foo' can be used interchangably here:
stopifnot( identical(isNamespaceLoaded( "foo" ), FALSE),
identical(isNamespaceLoaded(quote(foo)), FALSE),
identical(isNamespaceLoaded(quote(stats)), statL))
hasS <- isNamespaceLoaded("splines") # (to restore if needed)
Sns <- asNamespace("splines") # loads it if not already
stopifnot( isNamespaceLoaded("splines"))
unloadNamespace(Sns) # unloading the NS 'object'
stopifnot( ! isNamespaceLoaded("splines"))
if (hasS) loadNamespace("splines") # (restoring previous state)
# }