[R] adding zeroes after old zeroes in a vector ??

skan juanpide at gmail.com
Fri Sep 10 21:33:08 CEST 2010


Hi

I'll study your answers.

I could also try
gsub("01", "00", x)  N times
but it could be very slow if N is large
In fact when I wrote 111110011    I mean a vector
1
1
1
1
1
0
0
1
1
not a string, but I wrote it more compactly.

I also could by shifting the elements of the vector one position and ANDing
the result with the original. And again shifting 2 postions and so on up to
N. But it's very slow.
-- 
View this message in context: http://r.789695.n4.nabble.com/adding-zeroes-after-old-zeroes-in-a-vector-tp2534824p2534982.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list