Linear interpolation of NAs in a vector using `zoo::na.approx`. The NAs at the beginning or at the end are replaced by their first non NA neighbour

na_approx(vec)

Arguments

vec

A numeric vector with NAs

Value

A numeric vector without NA

Examples

na_approx(c(NA, 2, 3, NA, 5, 6, NA))
#> [1] 2 2 3 4 5 6 6