Rev 35391 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{showMethods}\alias{showMethods}\title{ Show all the methods for the specified function(s)}\description{Show a summary of the methods for one or more generic functions,possibly restricted to those involving specified classes.}\usage{showMethods(f = character(), where = topenv(parent.frame()),classes = NULL, includeDefs = FALSE, inherited = TRUE,showEmpty = TRUE, printTo = stdout())}\arguments{\item{f}{one or more function names. If omitted, all functionswill be examined. }\item{where}{If \code{where} is supplied, the methods definition fromthat position will be used; otherwise, the current definition isused (which will include inherited methods that have arisen so farin the session). If \code{f} is omitted, \code{where} controlswhere to look for generic functions.}\item{classes}{ If argument \code{classes} is supplied, it is a vectorof class names that restricts the displayed results to those methodswhose signatures include one or more of those classes. }\item{includeDefs}{ If \code{includeDefs} is \code{TRUE}, include thedefinitions of the individual methods in the printout. }\item{inherited}{ If \code{inherits} is \code{TRUE}, then methods thathave been found by inheritance, so far in the session, will beincluded and marked as inherited. Note that an inherited methodwill not usually appear until it has been used in this session.See \code{\link{selectMethod}} if you want to know what method isdispatched for particular classes of arguments.}\item{showEmpty}{logical indicating if methods with empty method listsshould be shown at all. Notethat \code{FALSE} is \emph{not yet implemented}.}\item{printTo}{The connection on which the printed information will bewritten. If \code{printTo} is \code{FALSE}, the output will becollected as a character vector and returned as the value of thecall to \code{showMethod}. See \code{\link{show}}.}}\details{The output style is different from S-Plus in that it does not show thedatabase from which the definition comes, but can optionally includethe method definitions.}\value{If \code{printTo} is \code{FALSE}, the character vector that wouldhave been printed is returned; otherwise the value is the connectionor filename.}\references{The R package \pkg{methods} implements, with a few exceptions, theprogramming interface for classes and methods in the book\emph{Programming with Data} (John M. Chambers, Springer, 1998), inparticular sections 1.6, 2.7, 2.8, and chapters 7 and 8.While the programming interface for the \pkg{methods} package followsthe reference, the R software is an original implementation, sodetails in the reference that reflect the S4 implementation may appeardifferently in R. Also, there are extensions to the programminginterface developed more recently than the reference. For adiscussion of details and ongoing development, see the web page\url{http://developer.r-project.org/methodsPackage.html} and thepointers from that page.}\seealso{\code{\link{setMethod}}, and \code{\link{GenericFunctions}}for other tools involving methods;\code{\link{selectMethod}} will show you the method dispatched for aparticular function and signature of classes for the arguments.}\examples{\dontshow{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")\dontrun{Function "plot":x = ANY, y = trackx = track, y = missingx = track, y = ANY}## Show all methods from the same place that a class is defined:%% FIXME: should improve the default of 'where'not.there <- !any("package:stats4" == search())if(not.there) library(stats4)showMethods(class = "mle") # not really helpfulshowMethods(class = "mle", where = "package:stats4") # much better%% FIXME(2): rather don't show those with <Empty Methods List>if(not.there) detach("package:stats4")}\keyword{methods}