Puzzle for the R cognoscenti: Say we have a data-frame:
df <- data.frame( a = 1:5, b = 1:5 )
I know we can do things like
The lattice package does this sort of thing in a different way. See, e.g., lattice:::xyplot.formula.
lattice:::xyplot.formula
fn <- function(dat, expr) { eval(substitute(expr), dat) } fn(df, a) # 1 2 3 4 5 fn(df, 2 * a + b) # 3 6 9 12 15