
Last chance! 50% off unlimited learning
Sale ends in
showMethods(f = character(), where = topenv(parent.frame()), classes = NULL, includeDefs = FALSE, inherited = !includeDefs, showEmpty, printTo = stdout(), fdef)
The argument can also be an expression that evaluates to a single
generic function, in which
case argument fdef
is ignored. Providing an expression for
the function allows examination of hidden or anonymous functions;
see the example for isDiagonal()
.
f
is missing, or length 0, this also
determines which generic functions to examine. If where
is
supplied, only the generic functions returned by
getGenerics(where)
are eligible for printing. If
where
is also missing, all the cached generic functions are
considered.classes
is 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.includeDefs
is TRUE
, include the
definitions of the individual methods in the printout.selectMethod
if you want to know what method would be
dispatched for particular classes of arguments.TRUE
if and only if argument f
is not
missing.where
if that is specified.
See also comment in ‘Details’.printTo
is FALSE
, the character vector that would
have been printed is returned; otherwise the value is the connection
or filename, via invisible
.
When more than one generic function is involved, either as specified or
because f
was missing, the functions are found and
showMethods
is recalled for each, including the generic as the
argument fdef
. In complicated situations, this can avoid some
anomalous results.
Chambers, John M. (1998) Programming with Data Springer (For the original S4 version.)
setMethod
, and GenericFunctions
for other tools involving methods;
selectMethod
will show you the method dispatched for a
particular function and signature of classes for the arguments.
require(graphics)
## 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")
## Not run:
# # 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 generic
# ## End(Not run)
not.there <- !any("package:stats4" == search())
if(not.there) library(stats4)
showMethods(classes = "mle")
if(not.there) detach("package:stats4")
Run the code above in your browser using DataLab