[R] Save values from an expression that is created from deriv command
Gabor Grothendieck
ggrothendieck at gmail.com
Sat May 23 18:53:47 CEST 2009
Try this:
D(expression(x*x), "x")
On Sat, May 23, 2009 at 12:46 PM, dimitris kapetanakis
<gamitor at gmail.com> wrote:
>
> Dear all,
>
> I want to save a value from an expression that I created by using the deriv
> function. So for example the output from an expression using the deriv
> command is:
>
> expression({
> .expr7 <- 4 * b.nox.2^2 - 12 * b.nox.3 * b.nox.1
> .expr9 <- -2 * b.nox.2 - sqrt(.expr7)
> .expr10 <- 6 * b.nox.3
> .value <- .expr9/.expr10
> .grad <- array(0, c(length(.value), 1L), list(NULL, c("b.nox.3")))
> .grad[, "b.nox.3"] <- 0.5 * (12 * b.nox.1 * .expr7^-0.5)/.expr10 -
> .expr9 * 6/.expr10^2
> attr(.value, "gradient") <- .grad
> .value
> })
>
> The problem is that I do not know how to store the:
>
> .grad[, "b.nox.3"] <- 0.5 * (12 * b.nox.1 * .expr7^-0.5)/.expr10 -
> .expr9 * 6/.expr10^2
>
> and then use its numerical value in my code.
>
> How can I store the above value or any output from the expression from deriv
> command so I can use it later in the code?
>
> Any help would be highly appreciated
>
> Thanks
>
> Dimitris
> --
> View this message in context: http://www.nabble.com/Save-values-from-an-expression-that-is-created-from-deriv-command-tp23686186p23686186.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list