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

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Jul 26 16:42:22 CEST 2004

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

More information about the R-help mailing list