From ripley at stats.ox.ac.uk  Tue Jun 24 18:50:08 2003
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue Jun 24 18:50:17 2003
Subject: [Rd] Putting an object in a data farme
In-Reply-To: <1gggfv0aa63o8eqtobj15qt9384gppfpcn@4ax.com>
Message-ID: <Pine.LNX.4.44.0306241747060.26052-100000@gannet.stats>

On Tue, 24 Jun 2003, Duncan Murdoch wrote:

> 
> I'd like to use the modelling functions, in particular  model.frame,
> with the S4 orientation objects I'm writing.  

That's probably not a good idea: I gave up for S-PLUS with S4 classes a 
long time back.  Too many utilities assumed that a classed object was a 
list with components like call and formula.

> However, these use
> data.frames, and data.frames object to having my objects put in them.
> model.frame checks the mode of the object before it puts it in;
> data.frame seems to be trying to coerce my class to data.frame, and
> it's failing.
> 
> What's necessary to put a nonstandard object into a data.frame?

You need either to enclose it in I() or write an as.data.frame method for 
it, which may be difficult if it does not have an S3 class.

Brian

-- 
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] Putting an object in a data farme
Prof Brian Ripley