approx1: Resampling in 1D with Interpolation

View source: R/signal.R

approx1R Documentation

Resampling in 1D with Interpolation

Description

Resample the given data at specified points. Interpolation can be performed within a tolerance using several interpolation methods.

Usage

approx1(x, y, xout, interp = "linear", n = length(x),
	tol = NA_real_, tol.ref = "abs", extrap = NA_real_)

Arguments

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 xout is not given, then interpolation is performed at n equally spaced data points along the range of x.

tol

The tolerance for the data points used for interpolation. Must be nonnegative. If NA, then the tolerance is estimated from the maximum differences in x.

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 tol.

Details

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.

Value

A vector of the same length as xout, giving the resampled data.

Author(s)

Kylie A. Bemis

See Also

asearch, approx approx2

Examples

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

kuwisdelu/matter documentation built on May 1, 2024, 5:17 a.m.