String-based (continuous) unique ID runs C++

Usage

ruidvec(x, start = 0L)

Arguments

x
a vector of class "character"

Value

a vector of "numeric"

Description

For a vector strings, assigns each continuous run of particular string a unique ID.

Examples

ruidvec(c("One","One","Two","Three","Three","Two","Three","Three","One"))
[1] 1 1 2 3 3 4 5 5 6