Description Usage Arguments Value Examples
Get the parent, grandparent, grandgrandparent of an environment
1 | parent.nenv(env, n)
|
env |
an environment |
n |
how many steps to go up the chain, >= 0 |
An enclosing environment
1 2 3 4 5 6 7 8 9 10 11 | myfun <- function(x) {
myfun2 <- function(x2) {
x+x2
}
x <- x+1
return(myfun2)
}
parent.env(environment(myfun(1))) # That is myfuns environment
parent.env(parent.env(environment(myfun(1))))
# This is the environment in which myfun was defined, normally .GlobalEnv
parent.nenv(environment(myfun(1)), 2) # The same call, but clearer
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.