powered by
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
na.trim(x)
numeric vector
soundgen:::na.trim(c(NA, NA, 1:10, NA, 21:25, NA))
Run the code above in your browser using DataLab