Description Usage Arguments Details Note Author(s) References See Also Examples
User-level functions to manage namespaces not (yet) available in base R.
1 2 3 4 |
name |
string |
env |
namespace environment |
version |
version |
lib |
string naming the package/namespace to load |
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
).
These functions provide support for namespaces needed by some
low-level packages (e.g. devtools
and rdynload
)
requested by their respective authors.
Winston Chang, Daniel Adler, Hadley Wickham, Gregory R. Warnes, and code from the R 'base' package.
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
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.