getMethod(f, signature = character(), where = topenv(parent.frame()),
optional = FALSE, mlist, fdef)
| 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. |
# 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")