Hi all,

Does there already exist a version of substitute that evaluates it's
first argument? (i.e. it accepts an already quoted expression).  This
seems like something that's pretty handy, but I haven't found any
existing function to do it:

substitute_e <- function(expr, env) {
  eval(substitute(substitute(expr, env), list(expr = expr)))
}

f <- quote(x + y + z)

substitute(f, list(y = 1, z = as.name("b")))
substitute_e(f, list(y = 1, z = as.name("b")))

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to