powered by
Get parent/ancestor environment
parenv(env = parent.frame(), n = 1)
an environment
number of parents to go up
adder <- function(x) function(y) x + y add2 <- adder(2) parenv(add2)
Run the code above in your browser using DataLab