interpSpline {splines}R Documentation

Create an Interpolation Spline


Create an interpolation spline, either from x and y vectors (default method), or from a formula / data.frame combination (formula method).


interpSpline(obj1, obj2, bSpline = FALSE, period = NULL,
             ord = 4L,
             na.action =, sparse = FALSE)



either a numeric vector of x values or a formula.


if obj1 is numeric this should be a numeric vector of the same length. If obj1 is a formula this can be an optional data frame in which to evaluate the names in the formula.


if TRUE the b-spline representation is returned, otherwise the piecewise polynomial representation is returned. Defaults to FALSE.


an optional positive numeric value giving a period for a periodic interpolation spline.


an integer specifying the spline order, the number of coefficients per interval. ord = d+1 where d is the degree polynomial degree. Currently, only cubic splines (ord = 4) are implemented.


a optional function which indicates what should happen when the data contain NAs. The default action (na.omit) is to omit any incomplete observations. The alternative action causes interpSpline to print an error message and terminate if there are any incomplete observations.


logical passed to the underlying splineDesign. If true, saves memory and is faster when there are more than a few hundred points.


An object that inherits from (S3) class spline. The object can be in the B-spline representation, in which case it will be of class nbSpline for natural B-spline, or in the piecewise polynomial representation, in which case it will be of class npolySpline.


Douglas Bates and Bill Venables

See Also

splineKnots, splineOrder, periodicSpline.


require(graphics); require(stats)
ispl <- interpSpline( women$height, women$weight )
ispl2 <- interpSpline( weight ~ height,  women )
# ispl and ispl2 should be the same
plot( predict( ispl, seq( 55, 75, length.out = 51 ) ), type = "l" )
points( women$height, women$weight )
plot( ispl )    # plots over the range of the knots
points( women$height, women$weight )
splineKnots( ispl )

[Package splines version 4.4.1 Index]