Skip to content
Prev 37142 / 63424 Next

Large discrepancies in the same object being saved to .RData

I'm still a bit puzzled by the original question.  I don't think it
has much to do with .RData files and their sizes.  For me the puzzle
comes much earlier.  Here is an example of what I mean using a little
session
[1] 96345

### Now look at what happens when a function returns a formula as the
### value, with a big item floating around in the function closure:
+ junk <- rnorm(10000000)
+ y ~ x
+ }
[1] 10096355
y ~ x
### the extra Vcells are located.
372 bytes

### Does v0 have an enclosing environment?
<environment: 0x021cc538>
[1] "junk"
[1] 96355

### Now consider a second example where the object
### is not a formula, but contains one.
+ junk <- rnorm(10000000)
+ x <- 1:3
+ y <- rnorm(3)
+ lm(y ~ x)
+ }
[1] 10096455

### in this case, though, there is no 
### (obvious) enclosing environment
NULL
7744 bytes
Error in ls(envir = environment(v1)) : invalid 'envir' argument
[1] 96366
And in this second case, as noted by Julian Taylor, if you save() the
object the .RData file is also huge.  There is an environment attached
to the object somewhere, but it appears to be occluded and entirely
inaccessible.  (I have poked around the object components trying to
find the thing but without success.)

Have I missed something?

Bill Venables.

-----Original Message-----
From: r-devel-bounces at r-project.org [mailto:r-devel-bounces at r-project.org] On Behalf Of Duncan Murdoch
Sent: Sunday, 11 July 2010 10:36 AM
To: Paul Johnson
Cc: r-devel at r-project.org
Subject: Re: [Rd] Large discrepancies in the same object being saved to .RData
On 10/07/2010 2:33 PM, Paul Johnson wrote:
I don't know of one.  You can load the whole file into an empty 
environment, but then you lose information about "where did it come from"?

Duncan Murdoch
______________________________________________
R-devel at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel