title: Breaking ties based on repeated counts/Subsetting data in R
body: <p>I'm trying to come up with a reasonable (if not clever) way of subsetting some data. Assume that when I create a table from the original data, it looks like this:</p>
  <pre><code>testdat &lt;- data.frame(nom = c(&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;, &quot;E&quot;, &quot;F&quot;, &quot;G&quot;, &quot;H&quot;, &quot;I&quot;, 
  &quot;J&quot;, &quot;K&quot;), cts = c(100, 50, 35, 10, 10, 5, 4, 2, 1, 1, 1)) 
  </code></pre>
  <p>My idea was to cut the data after the first three points here (they all have unique name/count combinations) and then take points D, E, F, and G as a group (they are the first group with repeated counts), and then points I, J, and K (second group with repeated counts). Just in case it isn't clear what I mean by &quot;repeated counts,&quot; I mean that there's no difference between E and F except their name - they both appear 10 times in the data.</p>
  <p>This isn't searching for duplicates (since each row is unique), but it is (since there are repeated counts in the second column). We can assume that the order is always either decreasing or repeated; it never increases (the <code>table</code> results were sorted in decreasing order).</p>
  <p>How can I find the row (and row number) of the first time <code>cts</code> is repeated n times?</p>