loadedNamespaces
Loading and Unloading Namespaces

Description

Provides for namespace management.

Usage

loadNamespace(package, lib.loc = NULL, keep.source = 
    getOption("keep.source.pkgs"), partial = FALSE) 
requireNamespace(package, ..., quietly = FALSE)
unloadNamespace(ns)
attachNamespace(ns, pos = 2, depends = NULL, warn.conflicts = TRUE)
loadedNamespaces()
isNamespaceLoaded(name)

Arguments

package a character string or name. Specifies the name of the package to be loaded as a namespace.
lib.loc a character vector. Specifies the names of library directories. If lib.loc is NULL, .libPaths is used.
keep.source a logical value indicating whether the source code including comments are kept while loading a namespace. The default is the value of the option "keep.source.pkgs".
partial a logical value. If TRUE, the function is returned after making and registering the namespace and (optionally) loading the source code. If FALSE (the default), more additional operations such as running hook functions, and so on are completed before the function is returned.
ns a character string. Represents the namespace or the namespace object.
name a character string. Represents the namespace or the namespace object.
pos an integer value. Represents the position of the namespace to be attached in the search list.
depends a character vector. Represents dependent namespaces to assign to the ".Depends" variable in the attached environment.
... optional arguments to pass to loadNamespace. For example, lib.loc, keep.source, partial, and so on.
quietly a logical value. If TRUE, the error message is not shown a namespace fails to load. The default is FALSE.
warn.conflicts a logical value. If TRUE (the default), gives warning messages if the new objects conflict with the objects in the attached packages.

Details

Value
loadNamespacereturns the loaded name space object itself.
requireNamespacereturns TRUE invisibly if the namespace is loaded (that is, either if it was previously loaded or if it was loaded by this call). It returns FALSE if the name space cannot be loaded.
unloadNamespacereturns nothing invisibly.
attachNamespacereturns an invisible environment with "name" and "path" attributes (package name and path).
loadedNamespacesreturns a character vector with the names of the loaded name spaces.
isNamespaceLoadedreturns TRUE if name is the name of a currently-loaded namespace. Returns FALSE if name is not the name of a currently-loaded namespace.
See Also
isNamespace, attach, library.
Examples

loadedNamespaces() ns_stats4 <- loadNamespace("stats4") env <- attachNamespace(ns_stats4, pos = 3, depends = c("abc", "def")) env search() # search list get(".Depends", env = env) loadedNamespaces() unloadNamespace(ns_stats4) # equivalent to: unloadNamespace("stats4")

if (requireNamespace("Matrix")) { # use quality general version of expm if available Matrix::expm } else { # use homegrown version that works on nice symmetric matrices function(x) { eig <- eigen(x) eig$vectors %*% diag(exp(eig$values)) %*% t(Conj(eig$vectors)) } }

attachNamespace("stats4")

# Error: name space is already attached #attachNamespace("stats4", pos = 1) loadedNamespaces() unloadNamespace("stats4")

# Error: name space "graphics" is imported by "stats" # so it cannot be unloaded #unloadNamespace("graphics")

Package base version 6.0.0-69
Package Index