Get the definition of a class.
getClass (Class, .Force = FALSE, where) getClassDef(Class, where, package, inherits = TRUE)
the character-string name of the class, often with a
environment from which to begin the search for the definition; by default, start at the top-level (global) environment and proceed through the search list.
the name or environment of the package asserted to hold the
definition. If it is a non-empty string it is used instead of
logical; should the class definition be retrieved from
any enclosing environment and also from the cache? If
Class definitions are stored in metadata objects in a package
namespace or other environment where they are defined. When
packages are loaded, the class definitions in the package are cached in an internal
table. Therefore, most calls to
getClassDef will find the
class in the cache or fail to find it at all, unless
FALSE, in which case only the environment(s) defined by
where are searched.
The class cache allows for multiple definitions of the same class name in separate environments, with of course the limitation that the package attribute or package name must be provided in the call to
The object defining the class. If the class definition is not found,
getClassDef, either generates an error or, if
TRUE, returns a simple definition for the
class. The latter case is used internally, but is not typically
sensible in user code.
The non-null returned value is an object of class
Use functions such as
setClassUnion to create class definitions.
Chambers, John M. (2016) Extending R, Chapman & Hall. (Chapters 9 and 10.)
getClass("numeric") ## a built in class cld <- getClass("thisIsAnUndefinedClass", .Force = TRUE) cld ## a NULL prototype ## If you are really curious: utils::str(cld) ## Whereas these generate errors: try(getClass("thisIsAnUndefinedClass")) try(getClassDef("thisIsAnUndefinedClass"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.