How to save and load spline interpolation functions in R?
I need to create thousands and thousands of interpolation splines, each based on 5 pairs of (x, y) values. I would like to save them in a database (or csv file). How can I export / import them, say in a text format or as an array of real parameters to rebuild each function when I need them? If you are using the splinefun function from R base package stats , it is very easy to export its construction information. set.seed(0) xk <- c(0, 1, 2) yk <- round(runif(3), 2) f <- splinefun(xk, yk, "natural") ## natural cubic spline construction_info <- environment(f)$z str(construction_info) # $ method: