powered by
replicates(x)
rle
x <- c('a','b','a','a','b','a','c','c','c') data.frame(val=x,rep=replicates(x))
Run the code above in your browser using DataLab