Convert the TRUE
values in a vector into a sequence by groups of
values.
TrueSeq(inLogi, zero2NA = FALSE)
inLogi | The input logical vector. |
---|---|
zero2NA | Logical. Should the zeroes in the result be converted to
|
A numeric vector
http://stackoverflow.com/a/21328046/1270695
Ananda Mahto
#> [1] 1 0 2 2 0 3 3 3 0 0 4 4 4 4 4 0 0 0 0 5 5 5 5 5 5 #> [26] 5 0 6 6 0 0 0 7 0 8 8 0 9 0 0 0 0 10 0 0 0 0 0 11 11 #> [51] 0 12 0 0 13 13 0 0 0 14 14 0 0 0 0 0 0 15 0 0 0 0 16 16 16 #> [76] 0 0 17 17 0 0 0 18 18 18 0 19 0 20 0 21 21 0 0 22 22 22 0 0 23