approx(x, y, xout, method="linear", n=50, rule=1) approxfun(x, y, method="linear", rule=1)
x,y
| vectors giving the coordinates of the points to be interpolated. Alternatively a single plotting structure can be specified. | ||
xout
| an optional set of values specifying where interpolation is to take place. | ||
method
| this specifies the interpolation method to be used. Currently this is ignored and linear interpolation is always used. | ||
n
|
If xout is not specified, interpolation
takes place at |
approx performs linear interpolation of the given data points.
It returns a list containing components x, and y which
give the ordinates where interpolation took place and the interpolated
values.
approxfun returns a function which will perform linear
interpolation of the given data points. For a given set of x
values this function will return the corresponding interpolated
values. This is typically more useful than
approx.
See Also
spline.
Examples
x <- 1:10
y <- rnorm(10)
plot(x, y)
points(approx(x, y))
x <- 1:10
y <- rnorm(10)
f <- approxfun(x, y)
curve(f(x), 0, 10)