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)
:
expression((a+b*x)*(c+d*x))
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.
expression
for an output, create functions instead and usebody
to modify the contents of the function. – Rocray