I got an array similar to the one below, and want to replace all NAs with the
previous value.
99 8.2 b
NA 8.3 x
NA 7.9 x
98 8.1 b
NA 7.7 x
99 9.3 b
...

i.e. the first two NAs should be replaced to 99, whereas the last one should
be 98.

I would like to apply a function to reach row, checking if the value in col
1 is NA, and if it is, set the value to the previous row's col 1 value.

Haven't been able to do this without looping, which gets very slow for large
datasets...

--
View this message in context: 
http://r.789695.n4.nabble.com/Replacing-values-without-looping-tp3602247p3602247.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to