have a function that is
function1<-(a,b,c,d){
z = a+b
g = c+d
h <- function2(x,y)
} where function2 is in another file such that
function2<- function(x,y){
h <- x + z + g + y
return(h)
}
How can I share an environment with function1 such that function2 knows im talking about z and g in function1? The problem is I have too many variables from function1 actually so I want function2 to know that some variables in their function comes from function1...
I tried using environment(function2) <- environment() before the h <- function2(x,y) line in function1 but it doesnt seem to work. Would appreciate any insights on this! thanks!