[R] append for .Rdata?
Jessica Streicher
j.streicher at micromata.de
Mon Oct 22 09:45:52 CEST 2012
Two issues, one was that i just wanted to do some calculation and then save it without having to load the rest again beforehand and have to delete variables in my working environment so they don't get saved as well. The second was the issue that i'd like to have most of the data in one big file, but after a while it gets too big to hold it all in memory.
At the moment i'm creating several files, one for each "experiment", but that means i have to create and save some data more than once. I guess i could split of the stuff that is used in more than one experiment so its only around once. I'll take a look at the lazy-load stuff too, thanks.
On 10.10.2012, at 19:47, J Toll wrote:
> On Tue, Oct 9, 2012 at 10:35 AM, Jessica Streicher
> <j.streicher at micromata.de> wrote:
>> Can i somehow append objects to an .Rdata file?
>>
>> I didn't see an option for it in the save() method.
>>
>> dump() won't work since i have s4 objects in there.
>
>
> I'm not sure I completely understand the issues you're trying to work
> around, but I have two ideas for you. One is a simple pseudo-append
> function that loads the entire contents, adds the object, and saves
> the result. There are obviously memory issues with this strategy.
>
> appendRData <- function(robj, filename) {
>
> tmpEnv <- new.env()
>
> savedObjects <- load(filename, envir = tmpEnv)
>
> # quick check for name collisions
> stopifnot(!(deparse(substitute(robj)) %in% savedObjects))
>
> save(list = c(savedObjects, deparse(substitute(robj))),
> file = filename,
> envir = tmpEnv)
> }
>
> A second possibility is to convert your RData files to a lazy-load
> database as described by Simon Urbanek here:
>
> http://stackoverflow.com/questions/8700619/get-specific-object-from-rdata-file
> http://stackoverflow.com/questions/6550510/examining-contents-of-rdata-file-by-attaching-into-a-new-environment-possible
>
> HTH
>
>
> James
More information about the R-help
mailing list