[R] data.frame is slower than matrix?

Peng Yu pengyu.ut at gmail.com
Tue Dec 8 21:17:07 CET 2009


I'm doing some data manipulations. I thought originally that I should
use data.frame, as the elements in a data.frame can have multiple
types but the elements in a matrix has to be the same, which all the
data have to convert to strings if there is a single column that is
string.

However,  when I observed that if I change data.frame to matrix, my
program becomes hundred times faster. I'm wondering if it is in
general better to store and manipulate data in a matrix of strings and
then converted to data.frame whenever needed.




More information about the R-help mailing list