On 02/10/2013 10:12 AM, Frederic Fournier wrote:
Hello everyone,I am trying to pass an object cleanly between two independant environments, any ideas on how to do that? I have something like this: calling.function <- function(my.object) { ... ... local(source("function_to_which_I_want_to_pass_my_object.Rda", local = new.env(parent = .GlobalEnv))) # I can't change this part of the code } The calling function will be part of a package, so I don't want to use the global environment (that's the user's space, not a space that should be used by the packages). Writing a temp file is unclean for the same reason (and using the user's hard-drive is actually worse than using its space in R!). The package namespace is locked when the package is loaded, so using the package environment is not a perfect option either. I was wondering, is there a way to create a named environment in R? If it was possible to do that, then the calling function could 'assign' to the named-environment and the scripted function could 'get' from it and the problem would be solved.
name <- new.env() creates an environment named "name". Duncan Murdoch ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

