[R] How to find S4 generics? (was: inames() function and lmer())

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Jul 19 08:59:31 CEST 2006

On Tue, 18 Jul 2006, Spencer Graves wrote:

> *****
> ***** "methods" *****
> *****
> 	  You have asked an excellent question.  I can provide a partial answer 
> below.  First, however, I wish to pose a question of my own, which could 
> help answer your question:
> 	  How can one obtain a simple list of the available generics for a 
> class?  For an S3 class, the 'methods' functions provide that.  What 
> about an S4 class?  That's entirely opaque to me, if I somehow can't 
> find the relevant information in other ways.  For example, ?lmer-class 
> lists many but not all of the methods available for objects of class 
> 'lmer'.  I think I once found a way to get that, but I'm not able to 
> find documentation on it now.

It doesn't work the same way.  S3 generics are defined on a single 
argument and hence have methods for a class, and so it is relevant to ask 
what generics there are which have methods for a given class - but even 
then there can be other generics and other methods which dispatch on 
object from that class by inheritance (e.g. on "lm" for "glm" objects).

S4 generics dispatch on a signature which can involve two or more classes, 
and I guess the simplest interpretation of your question is

`what S4 generics are there which have methods with signatures mentioning 
this class'.

Given the decentralized way such information is stored, I think the only 
way to do that is to find all the generics currently available (via 
getGenerics or its synonym allGenerics) and then call showMethods on each 
generic.  In particular, methods are stored in the S4 generic and not in 
the package defining the method.

However, I suspect inheritance is much more important here, and there is 
no way to know if methods for class "ANY" actually work for a specific S4 


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