Re: [R] eval(parse(...)) only once in a function

2012-09-18 Thread Christof Kluß
Hi Thomas thx, already the e <- parse(text="df$str==12")[[1]] is nice. So I have not to call parse in my function! (The function is called very often, so it makes the program much faster.) And eval(bquote(function(df) b<-.(e))) is great! That's exactly what I was looking for. Christof Am 17-0

Re: [R] eval(parse(...)) only once in a function

2012-09-17 Thread Thomas Lumley
On Mon, Sep 17, 2012 at 6: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) > } > > but for performance "eval(parse(a))" should not be evaluated at each > function call, but should

Re: [R] eval(parse(...)) only once in a function

2012-09-17 Thread Heramb Gadgil
If you have a data frame "df" with a column "JT" Try this one: str <- "df$JT == 12" fun<-function(str){b<-eval(parse(text=str)) return(b)} fun(str) On Mon, Sep 17, 2012 at 11:57 AM, Christof Kluß wrote: > Hi > > I would like to have something like > > str <- "df$JT == 12" > > fun <- function(d

Re: [R] eval(parse(...)) only once in a function

2012-09-17 Thread David Winsemius
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))" s