[R] Using very large matrix

Duncan Murdoch murdoch at stats.uwo.ca
Wed Feb 25 12:37:53 CET 2009


Philipp Pagel wrote:
>> I have to use a very large matrix. Something of the sort of 
>> matrix(80000,80000,n) .... where n is something numeric of the sort 0.xxxxxx
>>
>> I have not found a way of doing it. I keep getting the error
>>
>> Error in matrix(nrow = 80000, ncol = 80000, 0.2) : too many elements specified
>>
>> Any suggestions? I have searched the mailing list, but to no avail. 
>>     
>
> A 80000x80000 matrix has 6.4 billion cells. If you assume 4 byte
> (32bit) for a double precision floating point number that's an
> impressive 25.6 Gb. Certainly does not fit into RAM on my machine.
>   

Doubles are 8 bytes, and R can't handle vectors that large, even if you 
have the memory.  (Indices are limited to 32 bit values even in 64 bit R.)

Duncan Murdoch




More information about the R-help mailing list