title: How to subset a dataframe based on columns from another dataframe?
body: <p>I have two data frames (<code>df1</code> and <code>df2</code>) and I want to subset df2 based on the first two columns contained in df1. For example,</p>
  
  <pre><code>df1 = data.frame(x=c(1,1,1,1,1),y=c(1,2,3,4,5),value=c(3,4,5,6,7))
  df2 = data.frame(x=c(1,1,1,1,1,2), y=c(5,3,4,2,1,6), value=c(8,9,10,11,12,13))
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/J2OSL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J2OSL.png" alt="enter image description here"></a></p>
  
  <p>As we can see, row 6 <code>(2,6)</code> in <code>df2</code>  is not included in <code>df1</code>, so I will just select row 1 to row 5 in df2. </p>
  
  <p>Also, I want to rearrange <code>df2</code> based on <code>df1</code>. The final result should be like this:</p>
  
  <p><a href="https://i.stack.imgur.com/HD4iB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HD4iB.png" alt="enter image description here"></a></p>
  
  <p>Thanks for any help.</p>