Hi, Could anyone please help me?
I'm running into memory issues when I load huge files in RStudio? Are there any best practices or special packages that I need to use when loading huge data files? Do I need to use any special packages?
Thanks in advance!
Any specific recommendations will depend on what kind of files they are and what you want to do with them. Also, check out these recent threads in case they will help:
How much ram do you have? What kind of data do you have? How big are the files on disk? (And...What do you want to do?)
- A first approach might be the useage of
ls()
,pryr::mem_used()
andpryr::object_size()
to determine, if there are any unnecessary objects in ram. If so, just userm()
. Be careful whenever you assign your data to another name and change the old or the new object afterwards (memory size might double). - If you have independent objects and just want to process each of them, you might just be able to use some looping pattern involving for example
readRDS()
andsaveRDS()
to have less objects in memory at the same time. - Otherwise, the other threads, mentioned above, might include more possibilities.
If you want to understand R's memory management in more detail, the memory chapter in Advanced R is a good start.