title: R: how to rbind two huge data-frames without running out of memory
body: <p>I have two data-frames <code>df1</code> and <code>df2</code> that each have around 10 million rows and 4 columns. I read them into R using RODBC/sqlQuery with no problems, but when I try to <code>rbind</code> them, I get that most dreaded of R error messages: <code>cannot allocate memory</code>. There have got to be more efficient ways to do an <code>rbind</code> more efficiently -- anyone have their favorite tricks on this they want to share? For instance I found this example in the doc for <code>sqldf</code>: </p>
  
  <pre><code># rbind
  a7r &lt;- rbind(a5r, a6r)
  a7s &lt;- sqldf("select * from a5s union all select * from a6s")
  </code></pre>
  
  <p>Is that the best/recommended way to do it?</p>
  
  <p><strong><em>UPDATE</em></strong>
  I got it to work using the crucial <code>dbname = tempfile()</code> argument in the <code>sqldf</code> call above, as JD Long suggests in his answer to <a href="https://stackoverflow.com/questions/1727772/quickly-reading-very-large-tables-as-dataframes-in-r">this question</a></p>