[R] Vector replace 0 elements without using a loop

rivercode aquanyc at gmail.com
Thu Oct 7 07:16:01 CEST 2010


Hi,

With a vector like:

x = c (22, 23, 22.5, 0,0,24, 0, 23.2, 23.5, 0,0,0, 26)

How can I replace the 0's with the previous last value without looping
through the vector ?

Something tells me I am missing the obvious.

Thanks,
Chris
-- 
View this message in context: http://r.789695.n4.nabble.com/Vector-replace-0-elements-without-using-a-loop-tp2966191p2966191.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list