On Sep 16, 2012, at 11:27 PM, Christof Kluß wrote: > Hi > > I would like to have something like > > str <- "df$JT == 12" > > fun <- function(df) { > > b <- eval(parse(str)) > > return(b) > } >
What are you trying to do? str <- quote(df$JT == 12) > but for performance "eval(parse(a))" should not be evaluated at each > function call, but should work as > > fun <- function(df) { > > b <- df$JT == 12 > > return(b) > } > > Do you have an idea how I can implement this? Implement what? And what issues regarding "performance" are relevant? What does it mean to "not evaluate at each function call"? str <- quote(df$JT == 12) fun <- function(df) { b<-eval(str) return(b) } df3 <- data.frame(JT=12) fun(df3) #[1] TRUE -- David Winsemius, MD Alameda, CA, USA ______________________________________________ R-help@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.