approx1 | R Documentation |
Resample the given data at specified points. Interpolation can be performed within a tolerance using several interpolation methods.
approx1(x, y, xout, interp = "linear", n = length(x),
tol = NA_real_, tol.ref = "abs", extrap = NA_real_)
x , y |
The data to be interpolated. |
xout |
A vector of values where the resampling should take place. |
interp |
Interpolation method. One of 'none', 'sum', 'mean', 'max', 'min', 'area', 'linear', 'cubic', 'gaussian', or 'lanczos'. |
n |
If |
tol |
The tolerance for the data points used for interpolation. Must be nonnegative. If |
tol.ref |
If 'abs', then comparison is done by taking the absolute difference. If 'x', then relative differences are used. |
extrap |
The value to be returned when performing extrapolation, i.e., in the case when there is no data within |
The algorithm is implemented in C and provides several fast interpolation methods. Note that interpolation is limited to using data within the given tolerance. This is also used to specify the width for kernel-based interpolation methods such as interp = "gaussian"
. The use of a tolerance also means that interpolating within the range of the data but where no data points are within the tolerance window is considered extrapolation. This can be useful when resampling sparse signals with large empty regions, by setting extrap = 0
, and setting an appropriate tolerance.
A vector of the same length as xout
, giving the resampled data.
Kylie A. Bemis
asearch
,
approx
approx2
x <- c(1.11, 2.22, 3.33, 5.0, 5.1)
y <- x^1.11
approx1(x, y, 2.22) # 2.42359
approx1(x, y, 3.0) # NA
approx1(x, y, 3.0, tol=0.2, tol.ref="x") # 3.801133
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.