Re: [R] How to find S4 generics?

From: Spencer Graves <>
Date: Thu 20 Jul 2006 - 04:34:59 EST

Dear Prof. Ripley:

Thanks very much.

          Am I correct then that the 'methods' function could, at least theoretically, be revised so methods(class=...) could identify both S3 and S4 methods (ignoring inheritance, as it does now, I believe)?

          I ask, because it's not always obvious (at least to me) what helper functions are available. Some but not all are mentioned in the documentation, and even if they are, they may not be featured prominently. For the S3 standard, methods(class=...) reports what's available, and it's faster and more reliable than scanning the help files. After I find something with methods(class=...), then I have better ideas for what to look for in the documentation.

	  Best Wishes,
	  Spencer Graves

Prof Brian Ripley wrote:
> 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.
> [...]
> mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu Jul 20 04:43:26 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 - 10:18:07 EST.

Mailing list information is available at Please read the posting guide before posting to the list.