na.trim: Trim leading and trailing NAs

View source: R/math.R

na.trimR Documentation

Trim leading and trailing NAs

Description

Internal soundgen function. Nearly 10 times faster than zoo::na.trim. Slightly slower solution: a[!cumprod(is.na(a)) & rev(!cumprod(is.na(rev(a))))]. See https://stackoverflow.com/questions/42759027/remove-leading-and-trailing-na

Usage

na.trim(x)

Arguments

x

numeric vector

Examples

soundgen:::na.trim(c(NA, NA, 1:10, NA, 21:25, NA))

soundgen documentation built on April 4, 2025, 3:44 a.m.