Show all the methods for the specified function(s) or class
Show a summary of the methods for one or more generic functions, possibly restricted to those involving specified classes.
showMethods(f = character(), where = topenv(parent.frame()), classes = NULL, includeDefs = FALSE, inherited = !includeDefs, showEmpty, printTo = stdout(), fdef) .S4methods(generic.function, class)
- one or more function names. If omitted, all functions
will be shown that match the other arguments.
The argument can also be an expression that evaluates to a single generic function, in which case argument
fdefis ignored. Providing an expression for the function allows examination of hidden or anonymous functions; see the example for
- Where to find the generic function, if not supplied as an
fis missing, or length 0, this also determines which generic functions to examine. If
whereis supplied, only the generic functions returned by
getGenerics(where)are eligible for printing. If
whereis also missing, all the cached generic functions are considered.
- If argument
classesis supplied, it is a vector of class names that restricts the displayed results to those methods whose signatures include one or more of those classes.
TRUE, include the definitions of the individual methods in the printout.
- logical indicating if methods that have been found by
inheritance, so far in the session, will be included and marked as
inherited. Note that an inherited method will not usually appear
until it has been used in this session. See
selectMethodif you want to know what method would be dispatched for particular classes of arguments.
- logical indicating whether methods with no defined
methods matching the other criteria should be shown at all. By
TRUEif and only if argument
fis not missing.
- The connection on which the information will be shown; by default, on standard output.
- Optionally, the generic function definition to use; if
missing, one is found, looking in
whereif that is specified. See also comment in
- generic.function, class
methods for a description of
The name and package of the generic are followed by the list of signatures for which methods are currently defined, according to the criteria determined by the various arguments. Note that the package refers to the source of the generic function. Individual methods for that generic can come from other packages as well.
When more than one generic function is involved, either as specified or
f was missing, the functions are found and
showMethods is recalled for each, including the generic as the
fdef. In complicated situations, this can avoid some
FALSE, the character vector that would have been printed is returned; otherwise the value is the connection or filename, via
Chambers, John M. (2008) Software for Data Analysis: Programming with R Springer. (For the R version.)
Chambers, John M. (1998) Programming with Data Springer (For the original S4 version.)
methods provides method discovery tools for light-weight
require(graphics) setClass("track", representation(x="numeric", y="numeric")) ## First, with only one object as argument: setMethod("plot", signature(x="track", y="missing"), function(x, y, ...) plot(slot(x, "x"), slot(x, "y"), ...)) ## Second, plot the data from the track on the y-axis against anything ## as the x data. setMethod("plot", signature(y = "track"), function(x, y, ...) plot(x, slot(y, "y"), ...)) setMethod("plot", "track", function(x, y, ...) plot(slot(x, "y"), y, ...)) ## Assuming the methods for plot ## are set up as in the example of help(setMethod), ## print (without definitions) the methods that involve class "track": showMethods("plot", classes = "track") # Function "plot": # x = ANY, y = track # x = track, y = missing # x = track, y = ANY require("Matrix") showMethods("%*%")# many! methods(class = "Matrix")# nothing showMethods(class = "Matrix")# everything showMethods(Matrix:::isDiagonal) # a non-exported genericif(no4 <- is.na(match("stats4", loadedNamespaces()))) loadNamespace("stats4") showMethods(classes = "mle") # -> a method for show() if(no4) unloadNamespace("stats4")