EVOLUTION-MANAGER
Edit File: findClass.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: Find Class Definitions</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 findClass {methods}"><tr><td>findClass {methods}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Find Class Definitions</h2> <h3>Description</h3> <p>Functions to find classes: <code>isClass</code> tests for a class; <code>findClass</code> returns the name(s) of packages containing the class; <code>getClasses</code> returns the names of all the classes in an environment, typically a namespace. To examine the definition of a class, use <code><a href="getClass.html">getClass</a></code>. </p> <h3>Usage</h3> <pre> isClass(Class, formal=TRUE, where) getClasses(where, inherits = missing(where)) findClass(Class, where, unique = "") ## The remaining functions are retained for compatibility ## but not generally recommended removeClass(Class, where) resetClass(Class, classDef, where) sealClass(Class, where) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>Class</code></td> <td> <p>character string name for the class. The functions will usually take a class definition instead of the string. To restrict the class to those defined in a particular package, set the <code><a href="getPackageName.html">packageSlot</a></code> of the character string.</p> </td></tr> <tr valign="top"><td><code>where</code></td> <td> <p>the <code><a href="../../base/html/environment.html">environment</a></code> in which to search for the class definition. Defaults to the top-level environment of the calling function. When called from the command line, this has the effect of using all the package environments in the search list. </p> <p>To restrict the search to classes in a particular package, use <code>where = asNamespace(pkg)</code> with <code>pkg</code> the package name; to restrict it to the <em>exported</em> classes, use <code>where = "package:pkg"</code> after the package is attached to the search list. </p> </td></tr> <tr valign="top"><td><code>formal</code></td> <td> <p><code><a href="../../base/html/logical.html">logical</a></code> is a formal definition required? For S compatibility, and always treated as <code>TRUE</code>.</p> </td></tr> <tr valign="top"><td><code>unique</code></td> <td> <p>if <code>findClass</code> expects a unique location for the class, <code>unique</code> is a character string explaining the purpose of the search (and is used in warning and error messages). By default, multiple locations are possible and the function always returns a list. </p> </td></tr> <tr valign="top"><td><code>inherits</code></td> <td> <p>in a call to <code>getClasses</code>, should the value returned include all parent environments of <code>where</code>, or that environment only? Defaults to <code>TRUE</code> if <code>where</code> is omitted, and to <code>FALSE</code> otherwise. </p> </td></tr> <tr valign="top"><td><code>classDef</code></td> <td> <p> For <code>resetClass</code>, the optional class definition. </p> </td></tr> </table> <h3>Functions</h3> <dl> <dt><code>isClass</code>:</dt><dd> <p>Is this the name of a formally defined class? </p> </dd> <dt><code>getClasses</code>:</dt><dd> <p>The names of all the classes formally defined on <code>where</code>. If called with no argument, all the classes visible from the calling function (if called from the top-level, all the classes in any of the environments on the search list). The <code>where</code> argument is used to search only in a particular package. </p> </dd> <dt><code>findClass</code>:</dt><dd> <p>The list of environments in which a class definition of <code>Class</code> is found. If <code>where</code> is supplied, a list is still returned, either empty or containing the environment corresponding to <code>where</code>. By default when called from the <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> session, the global environment and all the currently attached packages are searched. </p> <p>If <code>unique</code> is supplied as a character string, <code>findClass</code> will warn if there is more than one definition visible (using the string to identify the purpose of the call), and will generate an error if no definition can be found. </p> <p><em>The remaining functions are retained for back-compatibility and internal use, but not generally recommended.</em> </p> </dd> <dt><code>removeClass</code>:</dt><dd> <p>Remove the definition of this class. This can't be used if the class is in another package, and would rarely be needed in source code defining classes in a package. </p> </dd> <dt><code>resetClass</code>:</dt><dd> <p>Reset the internal definition of a class. Not legitimate for a class definition not in this package and rarely needed otherwise. </p> </dd> <dt><code>sealClass</code>:</dt><dd><p> Seal the current definition of the specified class, to prevent further changes, by setting the corresponding slot in the class definition. This is rarely used, since classes in loaded packages are sealed by locking their namespace. </p> </dd> </dl> <h3>References</h3> <p>Chambers, John M. (2016) <em>Extending R</em>, Chapman & Hall. (Chapters 9 and 10.) </p> <p>Chambers, John M. (2008) <em>Software for Data Analysis: Programming with R</em> Springer. (Chapter 9 has some details not in the later reference.) </p> <h3>See Also</h3> <p><code><a href="getClass.html">getClass</a></code>, <code><a href="Classes_Details.html">Classes_Details</a></code>, <code><a href="Methods_Details.html">Methods_Details</a></code>, <code><a href="setSClass.html">makeClassRepresentation</a></code> </p> <hr /><div style="text-align: center;">[Package <em>methods</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>