you need rle(), e.g.,
x <- c(0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0)
rle(x)$lengths
I hope it helps.
Best,
Dimitris
dbajic at cnb.csic.es wrote:
Hello everyone,
I am a newbie, working on a gene clustering problem, and I have problems
in summarizing a logical string into number of repeats of each value. In
other words, how could I obtain from
0 1 1 1 0 0 0 0 1 1 0 1 0 0
this: 1 3 4 2 1 1 2
so a string that gives me the number of repeated values, no matter zeros
or ones.
I've been diving in the manuals and the mailing list but, nothing
interesting, apparently... I would be very grateful if anyone could give
me some advice.
Djordje Bajic
Logic of Genomic Systems Lab
Centro Nacional De Biotecnolog?a - CSIC
Cantoblanco, Madrid, Espa?a