[R] Combining expressions.

Turner Rolf r.turner at auckland.ac.nz
Sat Sep 5 04:22:56 CEST 2009


I am trying to construct a function to which I pass an expression as an argument.
>From that expression I want to create a somewhat more complicated expression
and then differentiate it using D() or deriv().

To give a simple example, I'd like to be able to do something like

e1 <- expression(x^2 + y^2)
e2 <- some.magic(e1,"n")

or maybe e2 <- some.magic(e1,expression(n))

and get e2 being expression((x^2+y^2)^n).  (Whence I can then do D(e2,"x") and D(e2,"y").)

Is there any way to accomplish this?

Thanks.

        cheers,

         Rolf Turner
######################################################################
Attention: 
This e-mail message is privileged and confidential. If you are not the 
intended recipient please delete the message and notify the sender. 
Any views or opinions presented are solely those of the author.

This e-mail has been scanned and cleared by MailMarshal 
www.marshalsoftware.com
######################################################################




More information about the R-help mailing list