Hi, I've been slowly transitioning to saving sets of objects for a project using save() rather than cluttering my workspace and then doing save.image() However, sometimes after I have done say: save(x,y,z, file='work.Rda') and I reload it a little later and I see that I also want to save object p. Currently I need to do: save(x,y,z,p, file='work.Rda') Is there any way to instruct save to append an object to a previously created binary data file? Thanks, ------------------------------------------------------------------- Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE ------------------------------------------------------------------- CChheecckk yyoouurr dduupplleexx sswwiittcchh..
On Fri, 10 Mar 2006, Rajarshi Guha wrote:> Hi, > I've been slowly transitioning to saving sets of objects for a project > using save() rather than cluttering my workspace and then doing > save.image() > > However, sometimes after I have done say: > > save(x,y,z, file='work.Rda') > > and I reload it a little later and I see that I also want to save > object p. Currently I need to do: > > save(x,y,z,p, file='work.Rda') > > Is there any way to instruct save to append an object to a previously > created binary data file?No. The save() format is not a concatenated set of objects. It is a serialized version of a single object, the R list of the objects named on the save() call. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
On Fri, 2006-03-10 at 03:46 -0500, Rajarshi Guha wrote:> Hi, > I've been slowly transitioning to saving sets of objects for a project > using save() rather than cluttering my workspace and then doing > save.image() > > However, sometimes after I have done say: > > save(x,y,z, file='work.Rda') > > and I reload it a little later and I see that I also want to save > object p. Currently I need to do: > > save(x,y,z,p, file='work.Rda') > > Is there any way to instruct save to append an object to a previously > created binary data file?I use this approach. One potential problem with this approach is that if you have large saved objects you could get into problems because you need to load them before saving them. ## Function to append an object to an R data file. append.Rda <- function(x, file) { old.objects <- load(file, new.env()) save(list = c(old.objects, deparse(substitute(x))), file = file) } ## Example: x <- 1:10 y <- letters[1:10] save(list = c("x", "y"), file = "temp.Rda") z <- "fred" append.Rda(z, "temp.Rda") Dave> > Thanks, > > ------------------------------------------------------------------- > Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net> > GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE > ------------------------------------------------------------------- > CChheecckk yyoouurr dduupplleexx sswwiittcchh.. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html