[R] appending objects to a file created by save()

2006-03-10 Thread Rajarshi Guha
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 [EMAIL PROTECTED] http://jijo.cjb.net
GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
---
CChheecckk yyoouurr dduupplleexx sswwiittcchh..

__
R-help@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


Re: [R] appending objects to a file created by save()

2006-03-10 Thread Prof Brian Ripley
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,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
R-help@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


Re: [R] appending objects to a file created by save()

2006-03-10 Thread David Whiting
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 [EMAIL PROTECTED] http://jijo.cjb.net
 GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
 ---
 CChheecckk yyoouurr dduupplleexx sswwiittcchh..
 
 __
 R-help@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

__
R-help@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


Re: [R] appending objects to a file created by save()

2006-03-10 Thread Adaikalavan Ramasamy
Another flexible approach is to zip/tar all the required individual .rda
files together. There are two advantages that I see :
 1) You can extract a single file from the collection if you want.
 2) You can easily list what objects are in the zipped/tarred file. 

In R you have to load all object from a single .rda if you want to
extract a single object or even to list what objects are stored.

In terms of size, the zipped/tarred file gives comparable if not smaller
size than R's function save() with compress=TRUE option. But I have
tested this feature in depth.

Regards, Adai



On Fri, 2006-03-10 at 09:49 +, David Whiting wrote:
 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 [EMAIL PROTECTED] http://jijo.cjb.net
  GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
  ---
  CChheecckk yyoouurr dduupplleexx sswwiittcchh..
  
  __
  R-help@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
 
 __
 R-help@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


__
R-help@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