I’m working in R, and I want to do, for example,
printx <- function() {
x <- 1
printy()
return(x)
}
printy <- function() {
print(x)
}
because I don’t want to keep passing around tons of variables (also, there is no x in the global environment). Is there a way to do this? All functions can access the global environment but what about the ones between the function’s environment and the global?
Maybe
This would use the
xto be printed byprintywhich was associated with the environment the function was called in.One other possibility would be to create a new environment