Re: [R] help(package)->sink()

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue 27 Jul 2004 - 00:42:22 EST


On Sun, 25 Jul 2004, Thomas Lumley wrote:

> On Sat, 24 Jul 2004, Spencer Graves wrote:
>
> >
> > 4. A request for "packageInfo.print" returned "object ... not
> > found".
>
> I think someone may have been contaminated by Java or some such. It should
> be print.packageInfo
>
> > A request for class(mclustInfo) confirmed that it was a
> > packageInfo object, so I tried getMethod("print", "packageInfo"); I
> > got, 'No generic function defined for "print"'. Then I tried,
> > getMethod("show", "packageInfo"); I got, 'No method defined for
> > function "show" and signature object = "packageInfo"'.
> >
>
> For S3 methods you need getS3method("print","packageInfo") rather than
> getMethod.
>
> People often recommend getAnywhere("print.packageInfo"), which does take
> less typing, but I prefer getS3method.

They are not exactly equivalent, though. Although I know of no actual examples, it is possible to register something like printPackageInfo() as the S3 method for print() for class "packageInfo". Then getS3method will work and getAnywhere will not.

The advantage of getAnywhere is that it is blunderbuss designed to pick up all possible matches for any sort of R object, which can be useful.

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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Tue Jul 27 02:14:20 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:55:15 EST