Search code examples
rmatrixr-bigmemory

Reload `filebacked.big.matrix` with R session crash


Thanks for reading this post!

Here I have an problem using big.matrix in R.With the code below:

big_matrix_object=as.big.matrix(matrix_object,backingfile='back.bin',descriptorfile='back.desc,backingpath='./path/)

if I save the big_matrix_object into the .RData.And the next time when I reload it the R session will encounter an crash.How can I avoid that?Appreciate your help!


Solution

  • Your big_matrix_object in R is a pointer to the backing file stored on the disk; it must be re-attached to the file each time after restarting an R session, even if the previous session's .RDATA file has been loaded. Fortunately an easy fix—after restarting R and reloading the bigmemory package, run:

    big_matrix_object <- attach.big.matrix("./path/back.desc") 
    

    This of course presumes the big.matrix object, and its associated backing file, were successfully created and saved in the prior session.

    Cheers!