title: Filter rows in R conditional on its value in comparison to other rows in the data frame
body: <p>I'm trying to create a reference list so that when I encounter a first name I am able to assign a gender to it. Complete accuracy is not important.</p>
  
  <p>I have a list of names, corresponding gender, and count of name/gender pair from the Social Security Administration in this form:</p>
  
  <pre><code>Name   Gender   Count  
  Aaron    F       10    
  Aaron    M       7246     
  Abbie    F       242    
  Abbie    M       8
  </code></pre>
  
  <p>As one can tell, there are lots of unisex names in the data. I want to get rid of the rare name/gender pairs when the name is both male and female. </p>
  
  <p>I always turn to dplyr with a problem like this, and I know that I could filter on absolute values such as when count > 100. However, I don't want to filter out rare names, just when that rare name/gender pair is much smaller than the other name/gender pair.</p>
  
  <p>How do I write code to accomplish something like this:</p>
  
  <p><code>filter x when Name=Name and Count &lt; 10*Count</code></p>
  
  <p><strong>EDIT:</strong> Thanks for the help guys. I realize that I was unclear in my initial post.</p>
  
  <p>I'd like to be able to have one record for names where I'm relatively sure of the gender. (e.g. Aaron from the above example would have Gender = M). This is why I'd like to create a filter rule for if the count of one gender/name pair is 10 times greater than the other gender/name pair. However, if the counts are close, I will assign this gender as U for unisex as we are not as positive in assigning a gender to this name. (Not worried about preserving the correct count value.)</p>
  
  <p>Expected output would be something like this:</p>
  
  <pre><code>Name  Gender Count
  Aaron M      7246
  Abbie F      242
  Alva  U      150
  </code></pre>