Generate a unique id for runs of consecutive values

consecutive_id(...)

Arguments

...

Vectors of values

Examples

x <- c(1, 1, 2, 2, 1, 1)
consecutive_id(x)
#> [1] 1 1 2 2 3 3