How to get the table counts for unique values in column

Viewed 137

I have this matrix mymat. I know I can do table((mymat[,"col1"]) to get the number of each item in col1. However, I only want the count if there are unique values in col2. For mymat below, I want this result:

app  gg  chh
 1    2   1

mymat

col1   col2
app    d
app    d
gg     e
gg     f 
gg     e
chh    f
chh    f
chh    f
4 Answers
Related