[R] Replacing NAs with interpolated values

Sven Garbade garbade at psy.uni-muenchen.de
Thu Sep 6 11:12:39 CEST 2001


Peter Dalgaard BSA wrote:
[snip] 
> 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

Thanks, this do the trick.

Bye, Sven
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list