I want to pass objects from one function to another nested function assigning environments. Below is a sample of my code which does not work. How this can happen by assigning environments in the function?
sumi <- function(x,y) {
my.env <- new.env()
my.env$rumi <- function() {
my.env$k <- x[1]
my.env$f <- y[1]
}
k <- get("k", my.env)
f <- get("f", my.env)
z <- k+f
return(z)
}
The code defines but then never runs
rumi
so the objects it would have created if run never are.Adding the line marked ### it works: