Re: [R] Summary method needed?

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Thu 03 Aug 2006 - 19:25:46 EST

>>>>> "HeinzT" == Heinz Tuechler <tuechler@gmx.at> >>>>> on Thu, 03 Aug 2006 09:39:35 +0100 writes:

    HeinzT> At 21:04 02.08.2006 +0100, Prof Brian Ripley wrote:

    >> On Wed, 2 Aug 2006, Christian Hennig wrote:
    >> 

>>> Thank you Brian!
>>>
>>> > > I'm updating my fpc package at the moment and will add some new functions.
>>> > > I learned that there should be print and summary methods for the key
>>> > > functions.
>>> >
>>> > for 'classes', I think.
>>>
>>> Yes.
>>>
>>> > > But in some cases the print method will make use of
>>> > > more or less all the output information of the
>>> > > function. Is there any reason to implement a summary
>>> > > method in these cases?
>>> >
>>> > Would a more concise print() method be useful? If so
>>> > the existing print() could become summary().
>>>
>>> :-)

>>> What I initially did some years ago was to write summary
>>> methods to print out the required informations. Then
>>> M. Maechler told me that this is not the purpose of a
>>> summary method and I should write a print.summary method
>>> for this. Now I realise that I actually just want to
>>> print, and I don't really need the extra "synopsis" to
>>> be done by summary().
>>>
>>> Now is there any recommendation on this? My intuition
>>> would be to write a print, but not a summary method.

    >> 
    >> That sounds fine for your purposes.
    >> 

    HeinzT> Maybe I am wrong, but as far as I see, print() has
    HeinzT> the disadvantage that it has to return x and must
    HeinzT> not return the summarized results as an object. You     HeinzT> remember the difficulties with print.survfit.

    HeinzT> Instead it seems to be allowed that summary does not     HeinzT> only print but also return summarized results.

    HeinzT> Is that right?

yes, that's right, But let me tell more on the story:

I think I had recommended summary.FOO() and print.summary.FOO() to Christian because he *did* compute a few `useful' things on his "FOO" object. In such a situation, we (R-core) recommend and usually (very rarely not; for back-compatibility reasons only) implement the following:

print.FOO: gives a one (sometimes two) paragraph overview of

	   the fitted model object, and
	   --yes-- *should* return its *unchanged* argument invisibly.

summary.FOO: computes more interesting things from the original
	     FOO object, does *NOT print* anything (explicitly)
	     and returns an object of class "summary.FOO".

print.summary.FOO: now prints (an overview of) the summary.FOO
	     object and -- since it's a print() method -- also
	     returns its argument unchanged and invisibly.

  Examples of the above, can be inspected e.g., for   'FOO' in { lm, glm, aov, nls, loess, princomp, prcomp, ...... }

For Joe Average User, of course it *looks* like summary( <FOO> ) would print , but that's just because it returns a summary.FOO object which is auto-printed subsequently -- unless it's assigned or used in another expression.

My reasons for *not* providing a summary.* and print.summary.* method would have to be either *both* of 1) and 2) *or* 3) :

  1. print(obj) gives enough information
  2. the 'obj' already contains the interesting quantities, or these are either trivially computable from the contents of 'obj' or are already provided by other FOO methods, e.g., vcov.FOO().
  3. lack of time and/or motivation; lazyness

Martin Maechler, ETH Zurich



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu Aug 03 19:33:32 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 03 Aug 2006 - 20:17:22 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.