[R] differentiating a numeric vector

Levi Waldron leviwaldron at gmail.com
Thu Mar 6 15:13:38 CET 2008


Thanks for all the ideas.  splinefun looks like the simplest way to
achieve what I need:

> x <- 1:10
> y <- x^2
> f <- splinefun(x,y)
> f(3,deriv=0)
[1] 9
> f(3,deriv=1)
[1] 6
> f(3,2)
[1] 2
> f(3,3)
[1] -3.330669e-16

The fda package has a function bsplineS which does nearly the same
thing, and the SemiPar solution looks good for irregular x and y
values, but the built-in function seems to work for my purposes.



More information about the R-help mailing list