Learn R Programming

soundgen (version 2.7.0)

intplNA: Interpolate NAs

Description

Internal soundgen function

Usage

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

Value

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab