Take the 2-minute tour ×  I am looking for a way to create an
expression that is the product of two given expressions. For
example, suppose I have  e1 <- expression(a+b*x) e2 <-
expression(c+d*x)  Now I want to create programatically the
expression (e1)*(e2):   Background I am writing a model fitting
function. The model has two pieces that are user-defined. I need
to be able to "handle" them separately, and then create a
combined expression and "handle" it as one model. "Handling"
involves taking numeric derivatives, and the deriv function
wants expressions as an input.  share|improve this question As a
side note: if you are in a similar situation but do not require
an expression for an output, create functions instead and use
body to modify the contents of the function. –  Carl Witthoft
Mar 2 '12 at 17:55 add comment  3 Answers  up vote 5 down vote
accepted  I don't deal with this too often but something like
this seems to be working  e1 <- expression(a + b*x) e2 <-
expression(c + d*x) substitute(expression(