The R Project SVN R

Rev

Rev 35633 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
27442 ripley 1
\name{methods}
2
\title{List Methods for S3 Generic Functions or Classes}
3
\alias{methods}
4
\alias{print.MethodsFunction}
5
\description{
6
  List all available methods for an S3 generic function, or all
7
  methods for a class.
8
}
9
\usage{
10
methods(generic.function, class)
11
}
12
\arguments{
13
  \item{generic.function}{a generic function, or a character string naming a
14
    generic function.}
15
  \item{class}{a symbol or character string naming a class: only used if
16
    \code{generic.function} is not supplied.}
17
}
18
\value{
19
  An object of class \code{"MethodsFunction"}, a
20
  character vector of function names with an \code{"info"} attribute.
21
  There is a \code{print} method which marks with an asterisk any
22
  methods which are not visible: such functions can be examined by
23
  \code{\link{getS3method}} or \code{\link{getAnywhere}}.
24
 
25
  The \code{"info"} attribute is a data frame, currently with a
26
  logical column, \code{visible} and a factor column \code{from}
27
  (indicating where the methods were found).
28
}
29
\details{
30
  Function \code{methods} can be used to find out about the methods for
31
  a particular generic function or class.  The functions listed are those
32
  which \emph{are named like methods} and may not actually be methods
33
  (known exceptions are discarded in the code).  Note that the listed
34
  methods may not be user-visible objects, but often help will be
35
  available for them.
36
 
37
  If \code{class} is used, we check that a matching generic can be found
38
  for each user-visible object named.
39
}
40
\note{
41
  This scheme is called \emph{S3} (S version 3).  For new projects,
42
  it is recommended to use the more flexible and robust \emph{S4} scheme
43
  provided in the \pkg{methods} package.  Functions can have both S3
44
  and S4 methods, and function \code{\link[methods]{showMethods}} will
45
  list the S4 methods (possibly none).
46
 
47
  The original \code{methods} function was written by Martin Maechler.
48
}
49
\seealso{
50
  \code{\link{S3Methods}}, \code{\link[base]{class}}, \code{\link{getS3method}}
51
}
52
\references{
53
  Chambers, J. M. (1992)
54
  \emph{Classes and methods: object-oriented programming in S.}
55
  Appendix A of \emph{Statistical Models in S}
56
  eds J. M. Chambers and T. J. Hastie, Wadsworth \& Brooks/Cole.
57
}
58
\examples{
59
methods(summary)
60
methods(class = "aov")
61
methods("[[")    ##- does not list the C-internal ones...
62
methods("$")     # currently none
63
methods("$<-")   # replacement function
64
methods("+")     # binary operator
65
methods("Math")  # group generic
66
\dontrun{methods(print)
67
}}
68
\keyword{methods}