intplNA: Interpolate NAs

View source: R/pitch_postprocessing.R

intplNAR Documentation

Interpolate NAs

Description

Internal soundgen function

Usage

intplNA(x, idx_na = NULL, nPoints = 1)

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.

Value

Returns the same numeric vector with NAs filled in by interpolation.

Examples

soundgen:::intplNA(c(NA, 405, 441, 460, NA, NA, NA, 480, 490, NA, NA))
soundgen:::intplNA(c(NA, 405, 441, 460, NA, NA, NA, 480, 490, NA, NA), nPoints = 3)

soundgen documentation built on Sept. 12, 2024, 6:29 a.m.