title: Subsetting data frame based on frequency
body: <p>I've been trying to figure out this problem for some time now. I have the following data frame with repeated observation by ID:</p>
  <pre><code>ID  color
  1   blue
  1   red
  1   blue
  2   red
  2   blue
  2   red
  .
  .
  .
  </code></pre>
  <p>I want to create a new data frame by choosing the color with the highest frequency for each ID so that I have only 1 row for each ID. That is, I'd like to get the following data frame:</p>
  <pre><code>ID  color
  1   blue
  2   red
  3
  .
  .
  .
  </code></pre>
  <p>I attempted using <code>transform</code> but that didn't work as it only summed the number of times each ID appeared in the data.
  <code>transform(df, freq.ID = ave(seq(nrow(df)), ID, FUN=length))</code></p>
  <p>Is there a way I can do this?</p>