Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to work with huge matrices in R? [closed]

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,

like image 433
John_Slinger Avatar asked Jun 16 '15 22:06

John_Slinger


2 Answers

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

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

like image 91
C8H10N4O2 Avatar answered Oct 11 '22 05:10

C8H10N4O2


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.

like image 25
Andrey Shabalin Avatar answered Oct 11 '22 07:10

Andrey Shabalin