Re: [R] differentiating a numeric vector

From: Levi Waldron <leviwaldron_at_gmail.com>
Date: Thu, 06 Mar 2008 09:13:38 -0500

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.



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. Received on Thu 06 Mar 2008 - 14:22:36 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 06 Mar 2008 - 14:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive