Finding the top level environment from an environment envir and its enclosing environments.
topenv(envir = parent.frame(),
matchThisEnv = getOption("topLevelEnvironment"))
| Parameter | Description |
|---|---|
envir |
environment. |
matchThisEnv |
return this environment, if it matches before any other criterion is satisfied. The default, the option topLevelEnvironment, is set by sys.source, which treats a specific environment as the top level environment. Supplying the argument as NULL means it will never match. |
# NOT RUN {
topenv(.GlobalEnv)
topenv(new.env()) # also global env
topenv(environment(ls))# namespace:base
topenv(environment(lm))# namespace:stats
# }