title: Remove duplicates, keeping most frequent row
body: <p>I would like to deduplicate my data, keeping the row that has the most frequent appearances. If there is a tie in rows, I don't care which gets returned—the first in alphabetical or numeric order is fine. I would like to do this by group of <code>id</code> and <code>var</code>.</p>
  
  <p>MRE:</p>
  
  <pre><code>df &lt;- data.frame(
    id = rep("a", 8),
    var = c(rep("b", 4), rep("c", 4)),
    val = c("d", "d", "d", "e", "f", "f", "g", "g")
  )
  
  &gt; df
    id var val
  1  a   b   d
  2  a   b   d
  3  a   b   d
  4  a   b   e
  5  a   c   f
  6  a   c   f
  7  a   c   g
  8  a   c   g
  </code></pre>
  
  <p>Should be:</p>
  
  <pre><code>  id var val
  1  a   b   d
  2  a   c   f
  </code></pre>
  
  <p>I'm working with large datasets and <code>tidyverse</code> pipe chains, so a <code>dplyr</code> solution would be preferable.</p>