 <p>Using data.table...</p> <pre><code>my_rows &lt;- seq.int(max(tabulate(df$Initials))) library(data.table) setDT(df)[ , .SD[my_rows], by=Initials] # Initials data # 1: a 2 # 2: a 3 # 3: b 4 # 4: b NA </code></pre> <p><code>.SD</code> is the <strong>S</strong>ubset of <strong>D</strong>ata associated with each <code>by=</code> group. We can subset its rows like <code>.SD[row_numbers]</code>, unlike a data.frame which requires an additional comma <code>DF[row_numbers,]</code>.</p> <p>The analogue in dplyr is</p> <pre><code>my_rows &lt;- seq.int(max(tabulate(df$Initials))) library(dplyr) setDT(df) %&gt;% group_by(Initials) %&gt;% slice(my_rows) # Initials data # (fctr) (dbl) # 1 a 2 # 2 a 3 # 3 b 4 # 4 b NA </code></pre> <p>Strangely, this only works if <code>df</code> is a data.table. I've filed <a href="https://github.com/hadley/dplyr/issues/1446" rel="nofollow">a report/query with dplyr</a>. There's a good chance that the dplyr devs will prevent this usage in a future version.</p>