On Mon, Sep 14, 2009 at 8:58 PM, Eduardo Leoni <[email protected]> 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 <[email protected]> :wq
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.