[R] features of save and save.image (unexpected file sizes)

Vaidotas Zemlys mpiktas at gmail.com
Wed Jan 31 18:03:41 CET 2007


Hi,

Today I came upon unexpected R behaviour. I did some modelling and the
result was R object,  about 28MB size (nested list, with matrixes as
list elements). When I was saving the session with save.image, the
resulting .RData file was 300MB. There were no other large objects:

> sum(sapply(ls(),function(x)eval(parse(text=paste("object.size(",x,")",sep=""))))/1024^2)
[1] 30.10540

The interesting thing, then I removed the large object with rm,
save.image again produced  .RData file with 300MB size. Only after
rm(list=ls()) I got normal sized .RData file. I used dump for dumping
my object, the resulting dump file was 72 MB in size. So I assume that
R was saving some large object which was not visible to me directly,
using ls(). Is there a way to find such objects, and discard them
before saving? I use R 2.4.1 on Ubuntu 6.06, through Emacs 23.0 and
ESS 5.3.1.

Vaidotas Zemlys
--
Doctorate student, http://www.mif.vu.lt/katedros/eka/katedra/zemlys.php
Vilnius University



More information about the R-help mailing list