namespace: Create, register, obtain a reference to, and unregister...

Description Usage Arguments Details Note Author(s) References See Also Examples

Description

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

Usage

1
2
3
4

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## 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")

namespace documentation built on May 1, 2019, 9:18 p.m.