Sorry if I'm asking something obvious, but couldn't find anything similar.
Suppose I have this data:
a<-c('blue','blue','green','red','black',
'white','blue','blue','blue','red',
'black','white','blue','green','red',
'black','white','white','black','white',
'blue','white','blue','green')
and would like to have it in a data frame, with a column that summarizes the number of times each element appears in the whole vector, no matter if it's redundant. Something like this:
data.frame(a=c('blue','blue','green','red',
'black','white','blue','blue',
'blue','red','black','white',
'blue','green','red','black',
'white','white','black','white',
'blue','white','blue','green'),
b=c(8,8,3,3,4,6,8,8,8,3,4,
6,8,3,3,4,6,6,4,6,8,6,8,3))
Any help would be appreciated.