From ripley at stats.ox.ac.uk  Thu Feb 26 20:31:15 2004
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu Feb 26 20:31:41 2004
Subject: [Rd] save() size in XDR
In-Reply-To: <ou8s3051ooa6n16dq46sdrn27s8e48kqpk@4ax.com>
Message-ID: <Pine.LNX.4.44.0402261929510.1840-100000@gannet.stats>

On Thu, 26 Feb 2004, Duncan Murdoch wrote:

> On Thu, 26 Feb 2004 08:21:05 -0800 (PST), Nathan Whitehouse
> <nlwhitehouse@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@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


[Rd] save() size in XDR
Prof Brian Ripley