e.g. substitute(f(x), list(f = function(x) x + 1)) # function (x) # x + 1(x) An extra pair of parentheses would really help: (function(x) x + 1)(x) (Better indenting etc would be nice, but not necessary for correct understand of the code) Hadley -- Chief Scientist, RStudio http://had.co.nz/