title: Selecting top N values within a group in a column using R
body: <p>I need to select top two values for each group[yearmonth] value from the following data frame in R. I have already sorted the data by count and yearmonth.How can I achieve that in following data?</p>
  
  <pre><code> yearmonth  name    count
  1   201310  Dovas   5
  2   201310  Indulgd 2
  3   201310  Justina 1
  4   201310  Jolita  1
  5   201311  Shahrukh Sheikh 1
  6   201311  Dovas   29
  7   201311  Justina 13
  8   201311  Lina    8
  9   201312  sUPERED 7
  10  201312  John Hansen 7
  11  201312  Lina D. 6
  12  201312  joanna1st   5
  </code></pre>