On Thu, Sep 30, 2010 at 09:34:26AM -0300, Henrique Dallazuanna wrote:
> You should try:
> 
> eapply(.GlobalEnv, I)[c('b', 'my.c')]

Great!

b <- c(22.4, 12.2, 10.9, 8.5, 9.2)
my.c <- sample.int(round(2*mean(b)), 4)

my.return <- function (vector.of.variable.names) {
  eapply(.GlobalEnv, I)[vector.of.variable.names]
}

str(my.return(c("b","my.c")))
List of 2
 $ b   :Class 'AsIs'  num [1:5] 22.4 12.2 10.9 8.5 9.2
 $ my.c:Class 'AsIs'  int [1:4] 18 22 12 3

much nicer than list(b=b, my.c=my.c), especially in real cases with
longer variable names and a lot of variables to return.

Thanks Henrique!

-- 
Hans Ekbrand (http://sociologi.cjb.net) <[email protected]>
Q. What is that strange attachment in this mail?
A. My digital signature, see www.gnupg.org for info on how you could
   use it to ensure that this mail is from me and has not been
   altered on the way to you.

Attachment: signature.asc
Description: Digital signature

______________________________________________
[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.

Reply via email to