[R] Expressions and Functions
Roger D. Peng
rpeng at jhsph.edu
Fri Nov 14 15:53:27 CET 2003
I can think of 2 ways:
f <- function(x) { }
body(f) <- D(expression(log(x)), "x")
Or maybe
g <- deriv(expression(log(x)), "x", function.arg = TRUE)
f <- function(x) { attr(g(x), "gradient") }
Or something along those lines.
-roger
Erin Hodgess wrote:
> Dear R People:
>
> When the D function is used for a symbolic derivative,
> an expression is returned, which is fine.
>
> How do you change that expression to a function, please?
>
> I've been experimenting with substitute and deparse, but no success
> yet.
>
> This is R 1.8.0 for Windows.
>
> thanks in advance for the help!
>
> Sincerely,
> Erin Hodgess
> mailto: hodgess at gator.uhd.edu
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
More information about the R-help
mailing list