[R] reporting multiple objects out of a function

andrewH ahoerner at rprogress.org
Wed Oct 5 19:45:17 CEST 2011


Thanks for the response, Paul!  But I thought these dumped the variables into
the global environment. Is that not correct? I want to make them available
in the calling environment, without making them available in the global
environment, unless that is where the function is called. This is my bow to
the fact that what I want this function to do is not good programming
practice in general.

The whole purpose of this function is to save me time, typing and wear on my
limited short-term memory capacity, by having standard objects with standard
names quickly available.

I wonder if eval.parent would do the job. Like:

fun1 <- function(x, y, z) eval.parent{obj1 <- x; obj2 <- y; obj3 <- z })

Or does that just use the parent environment for the inputs, not the output?
Part of my problem is that I am not sure how to tell if I have succeeded.
Otherwise I would just test it myself.

andrewH


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



More information about the R-help mailing list