Methods can be defined for the group generic functions by calls to
setMethod
in the usual way.
Note that the group generic functions
should never be called directly
-- a suitable error message will result if they are. When metadata
for a group generic is loaded, the methods defined become methods
for the members of the group, but only if no method has been
specified directly for the member function for the same signature.
The effect is that group generic definitions are selected before
inherited methods but after directly specified methods. For more on
method selection, see Methods
.There are also
S3 groups Math
, Ops
, Summary
and
Complex
, see ?S3groupGeneric
,
with no corresponding Robjects, but these are irrelevant for S4
group generic functions.
The members of the group defined by a particular generic can be
obtained by calling getGroupMembers
. For the group
generic functions currently defined in this package the members are
as follows:
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Note that Ops
merely consists of three sub groups.
All the functions in these groups (other than the group generics
themselves) are basic functions in R. They are not by default S4 generic
functions, and many of them are defined as primitives. However, you can still define
formal methods for them, both individually and via the group generics. It all works more or less as you
might expect, admittedly via a bit of trickery in the background.
See Methods for details.
Note that two members of the Math
group, log
and
trunc
, have ...as an extra formal argument.
Since methods for Math
will have only one formal argument,
you must set a specific method for these functions in order to call
them with the extra argument(s).
For further details about group generic functions see section 10.5 of
Software for Data Analysis.