uidvec(x, start = 0L)
"logical"
"numeric"
For a vector of logicals, assigns each continuous run of TRUE values a unique ID.
uidvec(c(FALSE,FALSE,TRUE,TRUE,TRUE,FALSE,TRUE,FALSE,TRUE,TRUE,FALSE,TRUE)) [1] 0 0 1 1 1 0 2 0 3 3 0 4