namespace {namespace}R Documentation

Create, register, obtain a reference to, and unregister namespaces

Description

User-level functions to manage namespaces not (yet) available in base R.

Usage

registerNamespace(name=NULL, env=NULL)
unregisterNamespace(name=NULL)
makeNamespace(name, version=NULL, lib=NULL)
getRegisteredNamespace(name)

Arguments

name

string

env

namespace environment

version

version

lib

string naming the package/namespace to load

Details

registerNamespace creates a new namespace entry with the provided environment.

unregisterNamespace removes an existing namespace.

makeNamespace creates a new namespace.

getRegisteredNamespace returns the specified namespace, or NULL if it is not loaded. (In R 2.16.0 this is just a wrapper for base::.getNamespace).

Note

These functions provide support for namespaces needed by some low-level packages (e.g. devtools and rdynload) requested by their respective authors.

Author(s)

Winston Chang, Daniel Adler, Hadley Wickham, Gregory R. Warnes, and code from the R 'base' package.

References

R-devel mailing list topic "[Rd] makeNamespace and rdyncall", Dec. 2011: https://stat.ethz.ch/pipermail/r-devel/2011-December/062838.html

R-devel mailing list topic "[Rd] rdyncall fears removal from CRAN", Aug 2012: https://stat.ethz.ch/pipermail/r-devel/2012-August/064659.html

See Also

ns-internal

Examples


## Get a reference to the namespace for the 'base' package
getRegisteredNamespace("base")

## Create a namespace, and stuff something into it.
ns <- makeNamespace("myNamespace")
assign("test",7, env=ns)
ls(env=ns)

## Now grab a reference to the namespace we just defined
ns2 <- getNamespace("myNamespace")



## Now unregister the namespace
unregisterNamespace("myNamespace")

## Returns NULL if it is no longer defined
getRegisteredNamespace("myNamespace")



[Package namespace version 0.9.1 Index]