[R] how "big" (in RAM and/or disk storage) is each of these objects in a list?

Uwe Ligges ligges at statistik.tu-dortmund.de
Thu Dec 1 10:54:05 CET 2011


On 26.11.2011 20:36, John wrote:
> On Sat, 26 Nov 2011 12:41:08 -0600
> Paul Johnson<pauljohn32 at gmail.com>  wrote:
>
>> Greetings, friends (and others :) )
>>
>> We generated a bunch of results and saved them in an RData file. We
>> can open, use, all is well, except that the size of the saved file is
>> quite a bit larger than we expected.  I suspect there's something
>> floating about in there that one of the packages we are using puts in,
>> such as a spare copy of a data frame that is saved in some subtle way
>> that has escaped my attention.
>>
>> Consider a list of objects. Are there ways to do these things:
>>
>> 1. ask R how much memory is used by the things inside the list?


A bit late, but hopefully still helpful:


See ?object.size

and particularly note

      Associated space (e.g. the environment of a function and what the
      pointer in a ‘EXTPTRSXP’ points to) is not included in the
      calculation.


>> 2.   Does "as.expression(anObject)" print everything in there? Or, is
>> there a better way to convert each thing to text or some other format
>> that you can actually read line by line to see what is in there, to
>> "see" everything?

See ?dump

and also carefully read the notes.


>>
>> If there's no giant hidden data frame floating about, I figure I'll
>> have to convert symmetric matrices to lower triangles or such to save
>> space.  Unless R already is automatically saving a matrix in that way
>> but just showing me the full matrix, which I suppose is possible. If
>> you have other ideas about general ways to make saved objects smaller,
>> I'm open for suggestions.

Look carefully for environments attached to one or more of the objects.

Best,
Uwe Ligges



>>
>
> As an initial step, what is the result of running ls() with your RData
> file loaded?  You should get a list of what is in memory.  Using RData
> files can be as space-efficient or costly as the user's habits.  Did you
> use save() or the save.image() command to produce the file? The
> save.image() command stashes what is in memory and if you've run a
> number of experimental procedures that did not pan out and you did not
> discard with the results with rm(), they were saved to the rdata file
> along with the information you did want, a procedure rather like filing
> away all your work in a file drawer and then emptying the waste basket
> into the drawer as well. If you save the data with ascii = TRUE as an
> option, you can troll through the file and read what you saved.
>
> JWD
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list