[R] generate simple function with pre-defined constants

Liviu Andronic
Thu, 06 Jun 2013 14:48:27 -0000

Dear all,
Given:
a <- 2
b <- 3

I'd like to obtain the following function:
f <- function(x) 2 + 3*x

but when I do this:
f <- function(x) a + b*x
##f
##function(x) a + b*x

the 'a' and 'b' objects do not get evaluated to their constants.
How
could I do that?

Thanks,