Skip to content
Back to formatted view

Raw Message

Message-ID: <971536df0905230953g30a78c80l82e5a968d87f7ef2@mail.gmail.com>
Date: 2009-05-23T16:53:47Z
From: Gabor Grothendieck
Subject: Save values from an expression that is created from deriv command
In-Reply-To: <23686186.post@talk.nabble.com>

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.
>