Learn R Programming

phonTools (version 0.1-2)

interpolate: Cubic Spline Interpolation

Description

Piece-wise 'natural' spline interpolation.

Usage

interpolate (y, x = 1:length(y), steps = 20, show = FALSE, output = TRUE, ...)

Arguments

y
a vector of 'knots', between which the function will interpolate points.
x
the 'x' coordinates corresponding to each knot. If not specified, the knots are assumed to be equally spaced.
steps
the number of interpolating steps between each knot. Increasing this number will result in a smoother interpolation.
show
if TRUE, the result of the interpolation is shown in a plot.
output
if TRUE, the interpolated values are returned.
...
additional arguments are passed to the internal call of plot if output = TRUE.

Value

  • If output = TRUE, a dataframe with columns corresponding to the x and y columns of the interpolated points is returned.
  • xthe x-axis coordinates of the inerpolated points.
  • ythe y-axis coordinates of the inerpolated points.

Details

This function performs a 'natural' cubic spline interpolation between the points provided by the user.

References

http://en.wikipedia.org/wiki/Spline_interpolation

Examples

Run this code
y = rnorm (10, 0, 5)
interpolate (y, output = FALSE, show = TRUE)

Run the code above in your browser using DataLab