How to work with huge matrices in R?

3k views Asked by At

I'm working with huge dense matrices in R (Matrix package, Matrix data type) where one of my matrix exceeds the theoretical limit of an R matrix (it is supposed to be 58932 by 58932)

I need to conduct basic matrix operations such as add and multiply.

My question is: Is there a package in R or some other software which I can use to store these huge matrices as well as work with them.

Thank you in advance,

2

There are 2 answers

0
C8H10N4O2 On

Try the class big.matrix in the CRAN package bigmemory.

http://www.stat.yale.edu/~mjk56/temp/bigmemory-vignette.pdf

1
Andrey Shabalin On

I mainly use Windows, so bigmemory does not work for me. I wrote my own package filematrix doing about the same with pure R code.

http://cran.r-project.org/web/packages/filematrix/index.html

I tested it on matrices over 1 TB in size. Your 60,000 x 60,000 matrix should take only 28 GB as a file.

Happy to answer any questions about it.