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

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed 19 Jul 2006 - 16:59:31 EST

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

[...]

-- 
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://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 Wed Jul 19 17:10:18 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 20 Jul 2006 - 06:16:16 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.