[R] reporting multiple objects out of a function

sina rueeger sina.rueeger at gmail.com
Wed Oct 5 19:18:37 CEST 2011


Hi Andrew

I am not sure if I understood your question entirely. You want to store some
objects, but not in the global environment. Correct?! I would do it like
this (although I am sure that there is a more elegant way to do this).

## ----------------------------------------------------------------
obj1 <- 2
attach(what = NULL, name = "my_env")  	## create new environment
assign("obj1", obj1, envir = as.environment("my_env"))  ## assign obj1 to
new environment

rm(list = ls()) ## remove all objects from global environment

obj1  ## still available
ls("my_env")  ## still available in environment "my_env"
## ----------------------------------------------------------------

Regards,
Sina

--
View this message in context: http://r.789695.n4.nabble.com/reporting-multiple-objects-out-of-a-function-tp3873380p3875488.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list