for example, this is my data
mydata
v
1 1
2 1
3 2
4 2
5 2
6 3
is there any function that can generate a vector or column like
v counts
1 1 2
2 1 2
3 2 3
4 2 3
5 2 3
6 3 1
I tried the method of sum()
,but failed
mydata$counts <- sum(mydata$v == mydata$v)