ns-topenv
Top Level EnvironmentFinding the top level environment
from an environment envir
and its enclosing environments.
topenv(envir = parent.frame(), matchThisEnv = getOption("topLevelEnvironment"))
envir | environment. |
matchThisEnv | return this environment, if it matches before any other criterion is satisfied. The default, the option topLevelEnvironment, is set by |
topenv
returns the first top level environment
found when searching envir
and its enclosing environments. If no top level environment is found, .GlobalEnv
is returned. An environment is considered top level if it is the internal environment of a namespace, a package environment in the search
path, or .GlobalEnv
.
environment
, notably parent.env()
on “enclosing environments”; loadNamespace
for more on namespaces.
topenv(.GlobalEnv) topenv(new.env()) # also global env topenv(environment(ls))# namespace:base topenv(environment(lm))# namespace:stats
Copyright (©) 1999–2012 R Foundation for Statistical Computing.
Licensed under the GNU General Public License.