From ripley@stats.ox.ac.uk  Fri Jan 31 00:02:05 2003
From: ripley@stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Fri Jan 31 00:02:05 2003
Subject: [Rd] print.default and attributes
In-Reply-To: <A8877251964B294BAB5BA1FC58B43FED025B44A5@molly.tas.csiro.au>
Message-ID: <Pine.LNX.4.44.0301302258320.9705-100000@gannet.stats>

As far as I can tell S2000 is a Honda sports car.  This is *R*-devel,
and in R typing x does not call print.default, let alone print.matrix.
Can you please check your facts a little?

The models that R considers are S-PLUS 3.4, and these days more often 6.1 
as R adopts ideas from S4.  S-PLUS 2000 (I guess you meant) is not very 
like either of those.

On Fri, 31 Jan 2003 Mark.Bravington@csiro.au wrote:

> #-----Original Message-----
> #From: ripley@stats.ox.ac.uk [mailto:ripley@stats.ox.ac.uk]
> #Sent: Thursday, 30 January 2003 6:42 PM
> #To: Mark.Bravington@csiro.au
> #Cc: r-devel@stat.math.ethz.ch
> #Subject: Re: [Rd] print.default and attributes
> #
> #
> #On Thu, 30 Jan 2003 Mark.Bravington@csiro.au wrote:
> #
> #> When something gets printed by the "print.default" function, 
> #any extra
> #> attributes are printed without regard to their class 
> #attribute (if any). 
> 
> << snipped >>
> 
> #
> #> BTW, the same applies to "print.matrix" (which doesn't rely 
> #on "print"), and
> #> perhaps to other print methods. Of course, it will also apply to any
> #> class-specific print method which invokes "print" or 
> #"NextMethod", too.
> #
> #In R-devel print.matrix *does* rely on print, and *is* a print method.
> #But the old-style prmatrix aka print.matrix does not print attributes 
> #normally:
> #
> #> x <- matrix(1:4, 2, 2)
> #> attr( x, 'other') <- factor( c( 'cat', 'dog'))
> #> prmatrix(x)
> #     [,1] [,2]
> #[1,]    1    3
> #[2,]    2    4
> #
> #So how did you make it print attributes?
> 
> Ummm... good point; I guess I didn't, despite thinking I had. All I did was
> type "x" instead of "prmatrix( x)" in what you've given above; in that case,
> the attributes are printed (albeit without regard to class).
> 
> My assumption was that, if "x" was a matrix (i.e. had a "dim" attribute),
> then "x" would be printed using "print.matrix" rather than "print.default".
> Evidently, more is going on. The R1.6.2 code for "print.default" and
> "print.matrix" is mostly .Internal, so I can't tell what's happening. But in
> S2000, FWIW, what happens is that "print.default" spots the presence of
> attributes and therefore calls "print.structure", which (i) spots the "dim"
> and therefore calls "print.matrix" (no attributes displayed) and then (ii)
> explicitly prints any extra attributes (by calling "print", so that
> attribute classes are respected).
> 
> cheers
> Mark
> 
> #
> #-- 
> #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
> #
> 
> 
> 
> *******************************
> 
> Mark Bravington
> CSIRO (CMIS)
> PO Box 1538
> Castray Esplanade
> Hobart
> TAS 7001
> 
> phone (61) 3 6232 5118
> fax (61) 3 6232 5012
> Mark.Bravington@csiro.au 
> 

-- 
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] print.default and attributes
ripley@stats.ox.ac.uk