how can I evaluate the derivative of a spline function in R?
R can generate a spline function using splinefun() in the splines library. However, I need to evaluate this function at its first and second derivatives. Is there a way to do this?
library(splines) x <- 1:10 y <- sin(pi/x) #just an example f_of_x <- splinefun(x,y)
How can I evaluate f'(x) for a vector of x's?
It is very easy to do since the ability to evaluate the function at its derivatives is built in to the function!
f_of_x(x, deriv = 1)