title: To speed up the tapply function in R, or another function to convert data frame into a matrix
body: <p>I need to convert a huge dataset into a matrix. The data structure likes the below data &quot;x&quot;. When I use the function tapply to do it (see below), it cannot work due to memory limit for the huge dataset.
  I am wondering if there is another way to do it. I tried for the R package dplyr, but didn't figure out how to do it. Any suggestion for that? Thanks so much.</p>
  <pre><code>x &lt;- data.frame(c1=c(&quot;A&quot;,&quot;B&quot;,&quot;C&quot;,&quot;A&quot;,&quot;B&quot;,&quot;C&quot;), c2=1:6, c3=c(&quot;sp1&quot;,&quot;sp2&quot;,&quot;sp2&quot;,&quot;sp2&quot;,&quot;sp3&quot;,&quot;sp4&quot;))
  y &lt;- tapply(x$c2, list(x$c1, x$c3), sum)
  </code></pre>