[R] how to get higher derivatives with "deriv"
mhofert
m_hofert at web.de
Mon Aug 2 00:20:19 CEST 2010
Dear all,
many thanks, great work. Here is the feature which Peter suggested (it also
includes a string containing the variable name):
DD <- function(f, var.string="x", order=1){
res <- f
body.res <- body(f)
i <- 1
while(i <= order){
body.res <- D(body.res,var.string)
i <- i + 1
}
body(res) <- body.res
res
}
f <- function(t,alpha) t^alpha
DD(f,"t",2)(2,3)
Cheers,
marius
--
View this message in context: http://r.789695.n4.nabble.com/how-to-get-higher-derivatives-with-deriv-tp2306711p2309761.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list