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 packagestats
, it is very easy to export its construction information.The following illustrates what they mean and how we may re-construct the spline manually.
There are n = 3 points,
(x[i], y[i])
, hence two pieces.We see that our manual re-construction is correct.
Exporting construction information allows us to move away from R and use it elsewhere.