Empty R environment becomes large file when saved
- by user1052019
I'm getting behaviour I don't understand when saving environments.
The code below demonstrates the problem. I would have expected the two files (far-too-big.RData, and right-size.RData) to be the same size, and also very small because the environments they contain are empty.
In fact, far-too-big.R ends up the same size as bigfile.RData.
I get the same results using 2.14.1 and 2.15.2, both on WinXP 5.1 SP3.
Can anyone explain why this is happening?
Thanks.
a <- matrix(runif(1000000, 0, 1), ncol=1000)
save(a, file="c:/temp/bigfile.RData")
test <- function() {
load("c:/temp/bigfile.RData")
test <- new.env()
save(test, file="c:/temp/far-too-big.RData")
test1 <- new.env(parent=globalenv())
save(test1, file="c:/temp/right-size.RData")
}
test()