If I have a vector such as :
c("A","A","B","B","A","C","C","C","D","A","B","C")
And I'm interested in numbering it, based upon repeats upon until they hit a new element. Such as:
1,1,2,2,3,4,4,4,5,6,7,8
How can I go about this? So far, I wrote this:
x <- map(seq_along(u), ~str_locate_all(str_flatten(u), u[[.x]]))