 <p>You can use <code>duplicated</code> to subset the data and then call <code>table</code>:</p> <pre><code>table(subset(df, !duplicated(paste(col1, col2)), select = col1)) #app chh gg # 1 1 2 </code></pre> <p>As a second option, here's a dplyr approach:</p> <pre><code>library(dplyr) distinct(df) %&gt;% count(col1) # or distinct(df, col1, col2) if you have other columns #Source: local data frame [3 x 2] # # col1 n # (fctr) (int) #1 app 1 #2 chh 1 #3 gg 2 </code></pre>