EVOLUTION-MANAGER
Edit File: methods.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: List Methods for S3 Generic Functions or Classes</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for methods {utils}"><tr><td>methods {utils}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>List Methods for S3 Generic Functions or Classes</h2> <h3>Description</h3> <p>List all available methods for a S3 and S4 generic function, or all methods for an S3 or S4 class. </p> <h3>Usage</h3> <pre> methods(generic.function, class) .S3methods(generic.function, class, envir=parent.frame()) ## S3 method for class 'MethodsFunction' print(x, byclass = attr(x, "byclass"), ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>generic.function</code></td> <td> <p>a generic function, or a character string naming a generic function.</p> </td></tr> <tr valign="top"><td><code>class</code></td> <td> <p>a symbol or character string naming a class: only used if <code>generic.function</code> is not supplied.</p> </td></tr> <tr valign="top"><td><code>envir</code></td> <td> <p>the environment in which to look for the definition of the generic function, when the generic function is passed as a character string.</p> </td></tr> <tr valign="top"><td><code>x</code></td> <td> <p>typically the result of <code>methods(..)</code>, an <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> object of class <code>"MethodsFunction"</code>, see ‘Value’ below.</p> </td></tr> <tr valign="top"><td><code>byclass</code></td> <td> <p>an optional <code><a href="../../base/html/logical.html">logical</a></code> allowing to override the <code>"byclass"</code> attribute determining how the result is printed, see ‘Details’.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>potentially further arguments passed to and from methods; unused currently.</p> </td></tr> </table> <h3>Details</h3> <p><code>methods()</code> finds S3 and S4 methods associated with either the <code>generic.function</code> or <code>class</code> argument. Methods are found in all packages on the current <code>search()</code> path. <code>.S3methods()</code> finds only S3 methods, <code>.S4methods()</code> finds only only S4 methods. </p> <p>When invoked with the <code>generic.function</code> argument, the <code>"byclass"</code> attribute (see Details) is <code>FALSE</code>, and the <code>print</code> method by default displays the signatures (full names) of S3 and S4 methods. S3 methods are printed by pasting the generic function and class together, separated by a ‘.’, as <code>generic.class</code>. The S3 method name is followed by an asterisk <code>*</code> if the method definition is not exported from the package namespace in which the method is defined. S4 method signatures are printed as <code>generic,class-method</code>; S4 allows for multiple dispatch, so there may be several classes in the signature <code>generic,A,B-method</code>. </p> <p>When invoked with the <code>class</code> argument, <code>"byclass"</code> is <code>TRUE</code>, and the <code>print</code> method by default displays the names of the generic functions associated with the class, <code>generic</code>. </p> <p>The source code for all functions is available. For S3 functions exported from the namespace, enter the method at the command line as <code>generic.class</code>. For S3 functions not exported from the namespace, see <code>getAnywhere</code> or <code>getS3method</code>. For S4 methods, see <code>getMethod</code>. </p> <p>Help is available for each method, in addition to each generic. For interactive help, use the documentation shortcut <code>?</code> with the name of the generic and tab completion, <code>?"generic<tab>"</code> to select the method for which help is desired. </p> <p>The S3 functions listed are those which <em>are named like methods</em> and may not actually be methods (known exceptions are discarded in the code). </p> <h3>Value</h3> <p>An object of class <code>"MethodsFunction"</code>, a character vector of method names with <code>"byclass"</code> and <code>"info"</code> attributes. The <code>"byclass"</code> attribute is a <code><a href="../../base/html/logical.html">logical</a></code> indicating if the results were obtained with argument <code>class</code> defined. The <code>"info"</code> attribute is a data frame with columns: </p> <dl> <dt>generic</dt><dd><p><code><a href="../../base/html/character.html">character</a></code> vector of the names of the generic.</p> </dd> <dt>visible</dt><dd><p>logical(), is the method exported from the namespace of the package in which it is defined?</p> </dd> <dt>isS4</dt><dd><p>logical(), true when the method is an S4 method.</p> </dd> <dt>from</dt><dd><p>a <code><a href="../../base/html/factor.html">factor</a></code>, the location or package name where the method was found.</p> </dd> </dl> <h3>Note</h3> <p>The original <code>methods</code> function was written by Martin Maechler. </p> <h3>References</h3> <p>Chambers, J. M. (1992) <em>Classes and methods: object-oriented programming in S.</em> Appendix A of <em>Statistical Models in S</em> eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole. </p> <h3>See Also</h3> <p><code><a href="../../base/html/UseMethod.html">S3Methods</a></code>, <code><a href="../../base/html/class.html">class</a></code>, <code><a href="getS3method.html">getS3method</a></code>. </p> <p>For S4, <code><a href="../../methods/html/getMethod.html">getMethod</a></code>, <code><a href="../../methods/html/showMethods.html">showMethods</a></code>, <a href="../../methods/html/Introduction.html">Introduction</a> or <code><a href="../../methods/html/Methods_Details.html">Methods_Details</a></code>. </p> <h3>Examples</h3> <pre> require(stats) methods(summary) methods(class = "aov") # S3 class ## The same, with more details and more difficult to read: print(methods(class = "aov"), byclass=FALSE) methods("[[") # uses C-internal dispatching methods("$") methods("$<-") # replacement function methods("+") # binary operator methods("Math") # group generic require(graphics) methods("axis") # looks like a generic, but is not if(require(Matrix)) { print(methods(class = "Matrix")) # S4 class m <- methods("dim") # S3 and S4 methods print(m) print(attr(m, "info")) # more extensive information ## --> help(showMethods) for related examples } </pre> <hr /><div style="text-align: center;">[Package <em>utils</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>