[R] getting caller's environment

Yi Zhang yizhang84 at gmail.com
Wed Jan 21 23:45:12 CET 2009


Hello,

I'm writing a function like this:

f<-function(x,y,...) {
...
assign(x,y,envir=?)
}

I need the caller (of f) 's environment for the "?" so that the
assignment is done at the right place. To be specific, when the code
"f(x,1)" appears in environment A, I need the assignment of 1 to x
happen in environment A. So my question is how to get the correct
environment?

Thanks for any suggestions!




More information about the R-help mailing list