Large Matrices in R: long vectors not supported yet

前端 未结 3 2290
Happy的楠姐
Happy的楠姐 2020-12-06 00:53

I am running 64 bit R 3.1 in a 64bit Ubuntu environment with 400GB of RAM, and I am encountering a strange limitation when dealing with large matrices.

I have a num

3条回答
  •  盖世英雄少女心
    2020-12-06 01:21

    An alternate, quick-hand solution would be to first get the row and then the column (now the i'th element of the resulting vector) of the matrix. For example ...

    test <- matrix(1,4000,900000) #no error 
    test[1,1] #error
    test[1, ][1] # no error
    

    Of course, this produces some overhead, as the whole row is copied/accessed first, but it's more straightforward to read. Also works for first extracting the column and then the row.

提交回复
热议问题