[R] defining a template for functions via do.call and substitute.

john.gavin@ubs.com john.gavin at ubs.com
Wed Sep 29 13:17:12 CEST 2004


Hi,

Given a function

  fun <- function(a, b) a + b

how do I generate the function 'function(x, y) x + y'?

Working from the help files and Bill Venables' R-news article (June 2002),
I have tried various permutations with substitute without success. 
e.g.
  do.call("substitute", list(fun, list(a = as.name("x"), b = as.name("y"))))

Regards,

John.

John Gavin <john.gavin at ubs.com>,
Quantitative Risk Models and Statistics,
UBS Investment Bank, 6th floor, 
100 Liverpool St., London EC2M 2RH, UK.
Phone +44 (0) 207 567 4289
Fax   +44 (0) 207 568 5352

Visit our website at http://www.ubs.com

This message contains confidential information and is intend...{{dropped}}




More information about the R-help mailing list