I am using R. Say I have the vector x
:
x <- c(1, 4, 3, 1, 5, 3, 4, 1, 2, 3)
And I want to count, for each value, the number of times that value has already appeared (or the number of times it appears to the left of that value).
In this example, the output would be:
1, 1, 1, 2, 1, 2, 2, 3, 1, 3
How do you do that?