[Rd] save() size in XDR

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Feb 26 20:31:15 MET 2004


On Thu, 26 Feb 2004, Duncan Murdoch wrote:

> On Thu, 26 Feb 2004 08:21:05 -0800 (PST), Nathan Whitehouse
> <nlwhitehouse at yahoo.com> wrote :
> 
> >Dear R-devel,
> >
> >  Is there a way to find the size in bytes of a save()
> >command --before-- the file has been saved?
> 
> I don't think so, though you can guess:  integers are stored in 4
> bytes, floats in 8, etc.
> 
> One way to solve this problem would be to create a connection that did
> nothing except keep track of a file position, then do the save to that
> connection.  However, it's not easy to define new connection types.
> Might be a nice package to write to allow such a thing.

I don't think it is worth it.  Just use an anonymous file connection and 
seek to the end to measure the length.  (Similar to Luke's use of a pipe, 
but more portable.)

-- 
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



More information about the R-devel mailing list