I have an expression stored in a variable
a <- expression(10 + x + y)
I want to use substitute to fill the expression with x = 2
substitute(a, list(x=2))
But this returns a
and a
evaluates to expression(10 + x + y)
Ideally a
would evaluate to expression(12 + y)
(or (10 + 2 + y)
)
Is there any way to implement this behavior while using an expression stored in the variable a
(mandated by other parts of my project)?