title: R - Number Unique Vals in Col1 of a Data Table when Col2 > Col3
body: <p>SampleTable:</p>
  
  <pre><code>ID      Score1      Score2
  1       100         88
  1       96          94
  1       94          95
  2       100         100
  2       98          94
  3       77          88
  </code></pre>
  
  <p>So I want the return value to be 2, since there are 2 unique people who have an instance where Score1 > Score2.</p>
  
  <p>For reproducability : </p>
  
  <pre><code>df = data.frame( ID=c(1,1,1,2,2,3), Score1=c(100,96,94,100,98,77), Score2=c(88,94,95,100,94,88) )
  ID Score1 S
  </code></pre>
  
  <p>I was thinking</p>
  
  <pre><code>length( unique( which( df$Score1 &gt; df$Score2 ) ) )
  </code></pre>
  
  <p>However that returns 3, clearly because it doesn't account for looking for the <code>df$ID</code> that is unique, just the number of unique occurences.  How do I account for wanting the unique number of unique <code>df$ID</code>?</p>