interpolate: Interpolation

interpolateR Documentation

Interpolation

Description

Piece-wise cubic or linear spline interpolation.

Usage

interpolate (y, x = 1:length(y), steps = 20, increment = -1, 
show = FALSE, type = 'cubic', ...)

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. If the knots are not equally spaced along the x-axis, the interpolated points will not be equally spaced across the entire curve.

increment

If this is greater than 0, interpolated points are separated along the x-axis by this value. Note that if the knot locations are not multiples of this increment, there will be irregularities in the spacing of the interpolated points.

show

If TRUE, the result of the interpolation is shown in a plot.

type

If 'cubic', a natural cubic spline interpolation is performed. If 'linear', a linear interpolation is performed.

...

Additional arguments are passed to the internal call of plot() if show = TRUE.

Details

By default, this function performs a 'natural' cubic spline interpolation between the points provided by the user. Optionally, a linear interpolation between the points may be carried out.

Value

A dataframe with columns corresponding to the x and y dimensions of the interpolated points is returned.

x

The x-axis coordinates of the interpolated points.

y

The y-axis coordinates of the interpolated points.

Author(s)

Santiago Barreda <sbarreda@ucdavis.edu>

References

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

Examples

## generate ten random points
#y = rnorm (10, 0, 5)
#interpolate (y, show = TRUE)  ## plot a cubic interpolation
#linear = interpolate (y, type = 'linear')   
## and compare to a linear interpolation
#lines (linear, col = 2) 

phonTools documentation built on Nov. 21, 2023, 1:07 a.m.