[R] R Memory Usage Concerns
Evan Klitzke
evan at eklitzke.org
Tue Sep 15 06:30:21 CEST 2009
On Mon, Sep 14, 2009 at 8:58 PM, Eduardo Leoni <leoniedu at msu.edu> wrote:
> And, by the way, factors take up _more_ memory than character vectors.
>
>> object.size(sample(c("a","b"), 1000, replace=TRUE))
> 4088 bytes
>> object.size(factor(sample(c("a","b"), 1000, replace=TRUE)))
> 4296 bytes
I think this is just because you picked short strings. If the factor
is mapping the string to a native integer type, the strings would have
to be larger for you to notice:
> object.size(sample(c("a pretty long string", "another pretty long string"), 1000, replace=TRUE))
8184 bytes
> object.size(factor(sample(c("a pretty long string", "another pretty long string"), 1000, replace=TRUE)))
4560 bytes
--
Evan Klitzke <evan at eklitzke.org> :wq
More information about the R-help
mailing list