getMethod
Get a Method for a Generic Function

Description

Returns the method for a generic function with a given signature.

Usage

getMethod(f, signature = character(), where = topenv(parent.frame()), 
          optional = FALSE, mlist, fdef)

Arguments

f a character string. The name of the generic function.
signature a character string. The signature of the method to return. If signature is not supplied, getMethod returns the default method.
where the package environment to search. Supply either an environment or a number representing its position in the search path.
optional a logical flag. If TRUE, returns NULL instead of an error message if no method is found. The default is FALSE.
mlist this argument is unimplemented, and a warning is generated if it is given. # an environment argument, or names of functions or MethodsList.
fdef a generic function object examined to find the specified method. If this is not given, a generic function is found with the name specified by f.

Details

Contrast this function with selectMethod, which finds the method that the generic would dispatch to evaluate a call using all the information about what classes extend other classes.
The getMethod function finds a method with exactly the given signature.
Value
returns a function definition.
See Also
selectMethod, existsMethod, hasMethod, findMethod, setMethod.
Examples
# create generic with default, and method
setGeneric("setG", function(x) standardGeneric("setG"),
           useAsDefault=function(x) x)
setMethod("setG", "numeric", function(x) x^2)

# get method taking "numeric" getMethod("setG", signature = "numeric")

# return NULL, since there is no method with signature "integer" getMethod("setG", signature = "integer", optional=TRUE)

# return default method getMethod("setG")

Package methods version 6.1.4-13
Package Index