Description Usage Arguments Details Value Author(s) References See Also Examples

Interpolation methods, including linear, spline, and cubic interpolation.

1 2 |

`x,y` |
vectors giving the coordinates of the points to be
interpolated. |

`xi` |
points at which to interpolate. |

`method` |
one of |

`extrap` |
if |

`...` |
for |

The following methods of interpolation are available:

`'nearest'`

: return nearest neighbour

`'linear'`

: linear interpolation from nearest neighbours

`'pchip'`

: piecewise cubic hermite interpolating polynomial

`'cubic'`

: cubic interpolation from four nearest neighbours

`'spline'`

: cubic spline interpolationâ€“smooth first and second
derivatives throughout the curve

The interpolated signal, an array of `length(xi)`

.

Original Octave version by Paul Kienzle pkienzle@user.sf.net. Conversion to R by Tom Short.

Octave Forge https://octave.sourceforge.io/

`approx`

, `filter`

,
`resample`

, `interp`

, `spline`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ```
xf <- seq(0, 11, length=500)
yf <- sin(2*pi*xf/5)
#xp <- c(0:1,3:10)
#yp <- sin(2*pi*xp/5)
xp <- c(0:10)
yp <- sin(2*pi*xp/5)
extrap <- TRUE
lin <- interp1(xp, yp, xf, 'linear', extrap = extrap)
spl <- interp1(xp, yp, xf, 'spline', extrap = extrap)
pch <- interp1(xp, yp, xf, 'pchip', extrap = extrap)
cub <- interp1(xp, yp, xf, 'cubic', extrap = extrap)
near <- interp1(xp, yp, xf, 'nearest', extrap = extrap)
plot(xp, yp, xlim = c(0, 11))
lines(xf, lin, col = "red")
lines(xf, spl, col = "green")
lines(xf, pch, col = "orange")
lines(xf, cub, col = "blue")
lines(xf, near, col = "purple")
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.