From ripley at stats.ox.ac.uk  Mon Aug 27 09:13:27 2007
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Mon, 27 Aug 2007 08:13:27 +0100 (BST)
Subject: [Rd] RData File Specification?
In-Reply-To: <0E49B2DD-8E31-4924-8A76-C21EE601626B@r-project.org>
References: <A312DAB4DB8DC34D86C006C5D8199D466BBB1C@ssvlexmb2.amd.com>
	<46CF1E3C.8000408@cimr.cam.ac.uk>
	<0E49B2DD-8E31-4924-8A76-C21EE601626B@r-project.org>
Message-ID: <Pine.LNX.4.64.0708270801390.20787@gannet.stats.ox.ac.uk>

On Fri, 24 Aug 2007, Simon Urbanek wrote:

>
> On Aug 24, 2007, at 2:06 PM, Hin-Tak Leung wrote:
>
>> I was going to write 'Use the source, Luke', but it seems that you
>> have
>> alreday found the relevant source files. I wrote a Python baed Rdata
>> writer and a reader sometimes ago just using that info and I am not
>> away of any file spec, so I know those two files are sufficient. For
>> what you want to do, I think you'll have to write some fairly
>> substantial code to process the Rdata as just XDR stream (as my python
>> scripts do, using the python built-in xdrlib),
>
>
> Unfortunately the format is not true XDR (it is not padded properly -
> CHARs (incl. symbols etc.) and raw vectors violate the padding
> rules), so you have to fall back to low-level access for some parts.
> It effect, the only part of XDR used is the storage of int and double
> (which is quite trivial), so IMHO any language (even without XDR)
> will do ...

I don't think XDR for doubles is 'quite trivial': it is if your native 
format is the conventional IEC60559 representation (when all you have to 
worry about is byte order), but not in general.  (Some of us remember 
interworking with Vaxen, for example.)

Note that the format is not actually claimed to be XDR: ?save says

      All R platforms use the XDR representation of binary objects in
      binary save-d files, and these are portable across all R
      platforms.

That was probably written before RAWSXPs, but it is not claiming that 
character strings are written in XDR.  (RFC 1832 seems to expect ASCII 
character strings, so XDR string format would be a pain to use.)

[...]

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



[Rd] RData File Specification?
Prof Brian Ripley