title: What's the fastest way to merge/join data.frames in R?
body: <p>For example (not sure if most representative example though):</p>
  
  <pre><code>N &lt;- 1e6
  d1 &lt;- data.frame(x=sample(N,N), y1=rnorm(N))
  d2 &lt;- data.frame(x=sample(N,N), y2=rnorm(N))
  </code></pre>
  
  <p>This is what I've got so far:</p>
  
  <pre><code>d &lt;- merge(d1,d2)
  # 7.6 sec
  
  library(plyr)
  d &lt;- join(d1,d2)
  # 2.9 sec
  
  library(data.table)
  dt1 &lt;- data.table(d1, key="x")
  dt2 &lt;- data.table(d2, key="x")
  d &lt;- data.frame( dt1[dt2,list(x,y1,y2=dt2$y2)] )
  # 4.9 sec
  
  library(sqldf)
  sqldf()
  sqldf("create index ix1 on d1(x)")
  sqldf("create index ix2 on d2(x)")
  d &lt;- sqldf("select * from d1 inner join d2 on d1.x=d2.x")
  sqldf()
  # 17.4 sec
  </code></pre>