f
with
signature
sig
. This may be defined explicitly for this signature or inferred by class extensions. Contrast this method with
getMethod
, which only works on methods actually defined for this specific function and signature, not using any class extensions. The
selectMethod
function returns
a function definition both for actual methods and for nongeneric functions. With no arguments, returns the method that would be selected for the call from which
selectMethod
is called.
NULL
.
This function searches only for "new-style" methods, those defined
using
setMethod
. "Old-style" methods
can be found using
methods
;
in addition, these functions have names of the form
generic.method
, for example
print.data.frame
is the
print
method for
a
data.frame
.
S searches for a matching method for a generic function using the following algorithm. First, it looks for a method that has an exact match of the signature. Second, it looks for a group generic method with an exact match of the signature. Third, it searches for methods that match using inherited classes. It searches for inherited-class methods starting with the last argument, and stops as soon as it finds a method for the function or group generic that matches a set of actual and inherited classes. Therefore, it will preferentially match a signature with the exact class for the first argument, and an inherited class for the second argument, over another method that might have an exact match for the second argument, and inherited class for the first argument.
selectMethod("plot") selectMethod("plot", "timeSeries") # finds the new-style plot method selectMethod("plot", "data.frame") # does not find the data frame method plot.data.frame # shows the old-style method