Reputation: 18239
Through iteration I construct a very big matrix and in order to speed up these iterations I split this matrix into chunks which I put in a list.
Would I have better to save my chunks of matrix into a text file and append the new chunk on this same text file instead of keeping them all in a list. Does it change anything in terms of memory use and performence (time to run the simulation) ?
second question: Is there a way to know the memory size of an R object (without having to save it into a .Rdata file)
Thank you in advance !
Upvotes: 1
Views: 339
Reputation: 7130
Retain the matrix in RAM if possible. Else you can also look into bigmemory package.
And the latest version of R has better support for large vectors. It will helpful if you have 64-bit machine with large amounts of RAM.
Note:Since we are talking about performance, it is a good practice to pre-allocate the matrix (instead of frequent use of rbind / cbind)
Upvotes: 1