[R] finding derivative of a data series in R

nandan amar nandan.amar at gmail.com
Fri May 27 10:23:40 CEST 2011


Dear All,
I tried following for getting derivative of a polynomial in R

i<- -10:10
x<-i*i*i+3*i*i+2
fun_spline<-splinefun(i,x)
plot(x,type="l")
lines(x,fx_spline(x, deriv=1), col='green')
lines(x,fx_spline(x, deriv=2), col='green')

Now when I plot
3*i*i + 6*i and 6*i + 6
the plot was not same for first deivative.
where as the 2nd derivative was same

Is this a correct method for getting derivative.
where am I doing wrong as first derivative  lines(x,fx_spline(x,
deriv=1), col='green') is not correct.

amar
--
Amar Kumar Nandan



More information about the R-help mailing list