I am trying to create a large sparse matrix, 10^5 by 10^5 in R, but am running into memory issues.
> Matrix(nrow=1e5,ncol=1e5,sparse=TRUE)
Error in Matrix(nrow = 1e+05, ncol = 1e+05, sparse = TRUE) :
too many elements specified
It looks like this is because the number of elements is larger than 2^31, which is the maximum integer value. But I am running this on a 64 bit machine.
> .Machine$integer.max
[1] 2147483647
Is there any way to create such a large, sparse matrix?
It looks like the trick is to set data=0
rather than data=NA
.
> Matrix(data=0,nrow=1e5,ncol=1e5,sparse=TRUE)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With