rleid | R Documentation |
For a vector, x
, rleid
creates a run-length group identifier
for by grouping sequential identical elements of x
.
rleid(x)
rleid2(x, na.rm = FALSE, ignore.na = FALSE)
x |
a logical, character, or numeric vector |
na.rm |
for |
ignore.na |
for |
rleid2
identifies the nth sequence of each unique value of x
.
An integer vector having the same length as x
.
rle
; data.table::rleid
x <- LETTERS[c(1, 1, 2, 1, 1, 2, 3, NA, 3, 3, 2, 3, 1, NA)]
data.frame(
id = x,
rleid = rleid(x),
rleid2 = rleid2(x, ignore.na = FALSE),
rleid2 = rleid2(x, ignore.na = TRUE)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.