Skip to contents

This intrapolation algorithm replaces internal missing values in a vector with the linear interpolation of the bounding non-missing values. If there are no-bounding non-missing values, the unbounded missing values are retained as missing. In our terminology, 'intrapolation' is distinct from 'interpolation' because interpolation might include 'extrapolation', that is, projecting estimates of values beyond the bounds. This function, in contrast, only replaces bounded missing values.

Usage

intrapolate_1D(v)

Arguments

v

numeric vector. A numeric vector.

Value

numeric vector of the same length as the input v with internal missing values linearly intrapolated.

Details

For example, the vector c(NA, NA, 1, NA, 5, NA, NA, 1, NA) will be intrapolated to c(NA, NA, 1, 3, 5, 3.7, 2.3, 1, NA).

Note: because intrapolation requires at least three elements (left bound, missing value, right bound), an input vector of less than three will be returned unchanged.