title: How do I match variables of different sizes?
body: <p>Suppose I have the following code:</p>
  
  <pre><code>color1 &lt;- c("red", "blue", "yellow", "orange", "green", "brown")
  assignment &lt;- c(1,2,3,4,9,13)
  color_df &lt;- as.data.frame(color1)
  color_df$assignment &lt;- assignment
  
  sport1 &lt;- c("basketball", "hockey", "baseball", "soccer", "tennis", "football", "volleyball")
  assignment &lt;- c(4,3,6,1,5,7,2)
  sport_df &lt;- as.data.frame(sport1)
  sport_df$assignment &lt;- assignment
  </code></pre>
  
  <p>When this is run, it yields the following two data frames:</p>
  
  <pre><code>  color1 assignment
  1    red          1
  2   blue          2
  3 yellow          3
  4 orange          4
  5  green          9
  6  brown         13
  
        sport1 assignment
  1 basketball          4
  2     hockey          3
  3   baseball          6
  4     soccer          1
  5     tennis          5
  6   football          7
  7 volleyball          2
  </code></pre>
  
  <p>I want to match the recurring assignment numbers to each other in another data frame, while removing the values from both data frames that do not have recurring assignment values. The desired output is below:</p>
  
  <pre><code>  color1     sport1 assignment
  1    red     soccer          1
  2   blue volleyball          2
  3 yellow     hockey          3
  4 orange basketball          4
  </code></pre>
  
  <p>How would I do this?</p>