Skip to content
Prev 13333 / 398502 Next

Replacing NAs with interpolated values

Torsten Hothorn <Torsten.Hothorn at rzmail.uni-erlangen.de> writes:
How about this:

y <- c(1, 2, NA, NA, NA, 10)
x <- seq(along=y)
approx(x,y,x)$y
#[1]  1  2  4  6  8 10