[R] D function

Douglas Bates bates at stat.wisc.edu
Sat Sep 16 16:57:52 CEST 2000


Erin Hodgess <hodgess at uhddx01.dt.uh.edu> writes:

> Suppose I put in the following:
> 
> > w1 <- expression(2*x)
> > v1 <- expression(x^2)
> 
> and I want to get the derivative of w1 * v1 with respect to x
> > D(w1*v1,"x")
> Error in w1 * v1 : non-numeric argument to binary operator
> Is there a way around this, please?

You need to create a single expression that does not refer to w1 and
v1.

> D(expression((2 * x) * (x * 2)), "x")
2 * (x * 2) + (2 * x) * 2
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list