[R] specify data frame by name

Greg Snow Greg.Snow at imail.org
Fri Oct 15 17:55:28 CEST 2010


Also look at the get function, it may be a bit more straight forward (and safer if there is any risk of someone specifying 'rm(ls())' as a data frame name).

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of darckeen
> Sent: Thursday, October 14, 2010 11:53 PM
> To: r-help at r-project.org
> Subject: Re: [R] specify data frame by name
> 
> 
> nvm, i figured it out.
> 
> 
> dfm <- data.frame(x=1:10)
> 
> testfunc <- function(data="dfm")
> {
> 	dat <- eval.parent(as.symbol(data))
> 	sum(dat$x)
> }
> 
> print(testfunc())
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/specify-
> data-frame-by-name-tp2996534p2996541.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org 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.



More information about the R-help mailing list