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.

______________________________________________
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