I have the following code:
e <- expression(x^2+3*x-3)
I want to draw a graph of the first derivative using the character function D of the character D:
curve(D(e), from=0, to=10)
But then I get the following error:
Error in curve(expression(e), xname = "x", from = 0, to = 3000) : 'expr' must be a function, or a call or an expression containing 'x'
I tried wrapping D (e) in an eval () call, but to no avail.
Try a little more:
substitute(expression(x^2+3*x-3), list(x=3))
as expected in:
expression(3^2+3*3-3)
But:
substitute(e, list(x=3))
leads to:
e
What's happening? How can I make this work?
r
Nanitous
source share