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

Christof Kluß ckluss at email.uni-kiel.de
Mon Sep 17 08:27:26 CEST 2012


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 work as

fun <- function(df) {

  b <- df$JT == 12

  return(b)
}

Do you have an idea how I can implement this?

Thx
Christof



More information about the R-help mailing list