findClass {methods} | R Documentation |
Functions to find classes: isClass
tests for a class;
findClass
returns the name(s) of packages containing the
class; getClasses
returns the names of all the classes in an
environment, typically a namespace. To examine the definition of a class, use getClass
.
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)
Class |
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
|
where |
the To restrict the search to classes in a particular package, use |
formal |
|
unique |
if |
inherits |
in a call to |
classDef |
For |
isClass
:Is this the name of a formally defined class?
getClasses
:The names of all the classes formally defined on where
. 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
where
argument is used to search only in a particular package.
findClass
:The list of environments in
which a class definition of Class
is found. If
where
is supplied, a list is still returned, either empty
or containing the environment corresponding to where
.
By default when called from the R session, the global
environment and all the currently
attached packages are searched.
If unique
is supplied as a character string,
findClass
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.
The remaining functions are retained for back-compatibility and internal use, but not generally recommended.
removeClass
: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.
resetClass
:Reset the internal definition of a class. Not legitimate for a class definition not in this package and rarely needed otherwise.
sealClass
: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.
Chambers, John M. (2016) Extending R, Chapman & Hall. (Chapters 9 and 10.)
Chambers, John M. (2008) Software for Data Analysis: Programming with R Springer. (Chapter 9 has some details not in the later reference.)
getClass
,
Classes_Details
,
Methods_Details
,
makeClassRepresentation