
Last chance! 50% off unlimited learning
Sale ends in
approx
, approx2 fills NAs in a vector with linear interpolation,
but unlike approx
, it can handle NAs at the ends of a vector
(takes the first/last value available for those). Also, approx2 returns a vector only.
approx2(x, fill = NULL, n = length(x), ...)
approx
approx
!)
na.rm=TRUE
as an argument.
The default (NULL) means to use the first (or last) observation available.
approx
, zoo::na.locf, ciBand
for usage example
is.error( approx2(c(NA,NA)) ) # yields an error
approx2(c(NA,NA, 6, 4, 8, 9, 3, 2, 1))
approx2(c( 2,NA, 6, 4, 8, 9, 3, 2, 1))
approx2(c( 2, 4, 6, 4, 8, 9,NA, 2,NA))
approx2(c(NA,NA, 6, 4, 8, 9, 3, 2, 1))
approx2(c(NA,NA, 6, 4, 8, 9, 3, 2, 1), fill=median)
approx2(c(NA,NA, 6, 4, 8, 9, 3, 2, 1), fill=mean)
approx2(c( 3, 4, 6, 4, 8, 9,NA, 2,NA))
approx2(c( 3, 4, 6, 4, 8, 9,NA, 2,NA), fill=median)
approx2(c( 3, 4, 6, 4, 8, 9,NA, 2,NA), fill=mean)
approx2(c(NA,NA, 6, 4, 8, 9, 3, 2, 1), n=17)
approx2(c( 2,NA, 6, 4, 8, 9, 3, 2, 1), n=17)
approx2(c( 2, 4, 6, 4, 8, 9,NA, 2,NA), n=17)
Run the code above in your browser using DataLab