Try this: attributes(eval(df1p))$gradient[,'P']
On Tue, Apr 6, 2010 at 9:09 AM, nickymcp <nickymcpher...@gmail.com> wrote: > > I am attempting to extract the derivative/ gradient from this expression > > df1p <- deriv(f1, "P") >> df1p > expression({ > .value <- s - c - a * P > .grad <- array(0, c(length(.value), 1L), list(NULL, c("P"))) > .grad[, "P"] <- -a > attr(.value, "gradient") <- .grad > .value > }) > > So in this case I want to extract the "-a". > > I have read the expression help file, which tells me that I should use [ and > [[ to extract information, but the best result I've had so far is > >> df1p[attr(f1,"gradient")] > expression() > > I'm sure I'm missing something really basic, but I've now lost several hours > trying to do this and I'm getting pretty desperate. > -- > View this message in context: > http://n4.nabble.com/Extracting-formulae-from-expression-deriv-tp1752738p1752738.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O ______________________________________________ R-help@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.