title: How to subset R data frame based on duplicates in one column and unique values in another
body: <p>This seems pretty straightforward but I am stumped. I have a data frame that looks like this:</p>
  <pre><code>df1 %&gt;% head()
    values  paired
    &lt;ch&gt;     &lt;int&gt;
  1 apples      1         
  2 x           1          
  3 oranges     2          
  4 z           2          
  5 bananas     3          
  6 y           3 
  7 apples      4
  8 p           4
  
  </code></pre>
  <p>I would like to create a new data frame that extracts all paired values based on a search criteria. So if I want all pairs that correspond to apples I would like to end up with something like this:</p>
  <pre><code>df1 %&gt;% head()
    values  paired
    &lt;ch&gt;     &lt;int&gt;
  1 apples      1         
  2 x           1                   
  3 apples      4
  4 p           4
  </code></pre>
  <p>I have tried using:</p>
  <pre><code>new_pairs &lt;- df1 %&gt;%
    arrange(values, paired) %&gt;%
    filter(duplicated(paired) == TRUE,
           values==&quot;apples&quot;) 
  </code></pre>
  <p>But I am getting only the apple rows back</p>