title: Merge two data frames while keeping the original row order
body: <p>I want to merge two data frames keeping the original row order of one of them (<code>df.2</code> in the example below).</p>
  
  <p>Here are some sample data (all values from <code>class</code> column are defined in both data frames):</p>
  
  <pre><code>df.1 &lt;- data.frame(class = c(1, 2, 3), prob = c(0.5, 0.7, 0.3))
  df.2 &lt;- data.frame(object = c('A', 'B', 'D', 'F', 'C'), class = c(2, 1, 2, 3, 1))
  </code></pre>
  
  <p>If I do:</p>
  
  <pre><code>merge(df.2, df.1)
  </code></pre>
  
  <p>Output is:</p>
  
  <pre><code>  class object prob
  1     1      B  0.5
  2     1      C  0.5
  3     2      A  0.7
  4     2      D  0.7
  5     3      F  0.3
  </code></pre>
  
  <p>If I add <code>sort = FALSE</code>:</p>
  
  <pre><code>merge(df.2, df.1, sort = F)                                                        
  </code></pre>
  
  <p>Result is:</p>
  
  <pre><code>  class object prob
  1     2      A  0.7
  2     2      D  0.7
  3     1      B  0.5
  4     1      C  0.5
  5     3      F  0.3
  </code></pre>
  
  <p>But what I would like is:</p>
  
  <pre><code>  class object prob
  1     2      A  0.7
  2     1      B  0.5
  3     2      D  0.7
  4     3      F  0.3    
  5     1      C  0.5
  </code></pre>