nsName <- "stats"
(ns <- asNamespace(nsName)) # <environment: namespace:stats>
## Inverse function of asNamespace() :
environmentName(asNamespace("stats")) # "stats"
environmentName(asNamespace("base")) # "base"
getNamespaceInfo(ns, "spec")[["name"]] ## -> "stats"
## Only for for the daring ones, trying to get into the bowels :
lsNamespaceInfo <- function(ns, ...) {
ns <- asNamespace(ns, base.OK = FALSE)
ls(..., envir = get(".__NAMESPACE__.", envir = ns, inherits = FALSE))
}
allinfoNS <- function(ns) sapply(lsNamespaceInfo(ns), getNamespaceInfo, ns=ns)
utils::str(allinfoNS("stats"))
utils::str(allinfoNS("stats4"))
Run the code above in your browser using DataLab