setMethod
Define a Method for a Generic Function

Description

Defines a method for a generic function.

Usage

setMethod(f, signature = character(), definition,
          where = topenv(parent.frame()), valueClass = NULL,
          sealed = FALSE) 

Arguments

f a character string. The name of the generic function for which this method is being defined.
signature a named list giving the formal argument names and argument classes of the method. The same rules are used as in matching positional and named arguments in function calls. Any arguments, and any number of arguments, can appear in the signature. Arguments that are missing from the signature correspond to "ANY"; that is, they match any class. In the simplest case, this can be a single class name, which specifies the class of the first argument.
definition a function definition for this method.
where the environment where the generic function is stored. Supply an environment or a number representing its position in the search path.
valueClass this argument is unused.
sealed this argument is unimplemented, and a warning is generated if it is given.
Value
returns a character string: the name of the generic function.
See Also
setGeneric, selectMethod.
Examples
setClass("myClass", contains="integer")
xx <- new("myClass", 123L)
setMethod("show", "myClass", function(object) cat("myClass:",object@.Data,"\n"))
show(xx)
Package methods version 6.1.1-7
Package Index