Skip to content
Prev 304770 / 398503 Next

Create a function to number each repeated visit or measurements

Hi

You did not provided any suitable data. 

x<-sort(sample(letters[1:5], 50, rep=T))
unlist(lapply(split(x,x), function(x) (1:length(x))-1))

gives you a vector of indices from 0 to n for sorted vector x.

Regards
Petr