[R] transfer local function objects to other environment - how?

Mark Heckmann mark.heckmann at gmx.de
Wed Mar 7 17:51:59 CET 2012


Hello,

I have an empty environment named env. 
Now I want the locally created objects in some function (foo) to appear in env.
Within the function I want to have straight forward code, no assign operation or env$x etc. in front of every command.  
What is the best way to do that?

Example:      

foo <- function(){
  x <- 1
  y <- 2
}
env <- new.env() 

Now I want to evaluate foo() but have the local variables x and y appear in env.

Thanks 
---Mark     
––––––––––––––––––––––––––––––––––––
Mark Heckmann
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com



More information about the R-help mailing list