Returns the same numeric vector with NAs filled in by interpolation.
Arguments
x
numeric vector
idx_na
which(is.na(x))
nPoints
the number of points to use for interpolating leading and
trailing NAs: 1 = constant interpolation, 2 = use the first two non-NAs at
the beginning and the last two non-NAs at the end, etc.
Details
Takes a numeric vector and fills in the NAs by linear
interpolation in the middle and constant or linear interpolation at the ends.