title: How to select matching rows from two data frames in r
body: <pre><code>&gt; df1
       n1 mt1
  1  Mike  48
  2  John  64
  3 Steve  32
  4   Dan  87
  
  &gt; df2
         n1 mt1
  1   Peter  32
  2   Chris  23
  3 Brendan  44
  4  Joseph  52
  </code></pre>
  
  <p>I would like to pick row 1 from df1 and df2. Row 2 from df1 and df2. Row 3 from df1 and df2. Row 4 from df1 and df2. I can do it with below code but wonder if there is a easier way to do it when there is hundreds of rows? I always seek the matching rows from both df's and would like them paired.</p>
  
  <pre><code>&gt; m1 &lt;- rbind(df1[1,], df2[1,])
  &gt; m2 &lt;- rbind(df1[2,], df2[2,])
  &gt; m3 &lt;- rbind(df1[3,], df2[3,])
  &gt; m4 &lt;- rbind(df1[4,], df2[4,])
  
  &gt; m1
       n1 mt1
  1  Mike  48
  2 Peter  32
  
  &gt; m2
        n1 mt1
  2   John  64
  21 Chris  23
  
  &gt; m3
          n1 mt1
  3    Steve  32
  31 Brendan  44
  
  &gt; m4
         n1 mt1
  4     Dan  87
  41 Joseph  52
  </code></pre>