[R] how "big" (in RAM and/or disk storage) is each of these objects in a list?
jwd at surwest.net
Sat Nov 26 20:36:23 CET 2011
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?
> 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?
> 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.
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.
More information about the R-help