[R] RAM usage

Liaw, Andy andy_liaw at merck.com
Mon Oct 21 14:23:54 CEST 2002


> From: Vaidotas Zemlys [mailto:mpiktas at delfi.lt]
> Hi,
> 
>  >> I'm having problems while working with large data sets 
> with R 1.5.1 in
>  >> windows 2000. Given a integer matrix size of 30 columns 
> and  15000 rows
>  >> my function should return a boolean matrix size of about 
> 5000 rows and
>  >> 15000 columns.
> 
>  >That's  75million items of 4bytes each, hence almost 300Mb 
> for that one
>  >object.
> 
> Does that mean that R reserves 4 bytes for logical object 
> with length 1? On 
> the whole how much memory R allocates for different data 
> types? I searched 
> a bit, but I didn't find anything useful on this subject. I 
> would like to 
> know if it is possible how much memory R needs for storing 
> for example real 
> matrix size of 50 rows and 100 columns together with column 
> and row names. 
> Or where to find information on such subject.
> 
> I thought that R needs only 1 byte for storing logical byte, 
> and because of 
> that I underestimated the size of memory R would need to use.

You can use object.size() to get some idea on how R allocates memory:

> object.size(logical(1000))/1000
[1] 4.028
> object.size(integer(1000))/1000
[1] 4.028
> object.size(double(1000))/1000
[1] 8.028

So it seems like R allocates logicals as if they are integers.  My guess is
that this makes it easier to coerce logicals to integers for things like
sum(is.na(x))?

Andy


------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it.

==============================================================================

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list