| Line 44... |
Line 44... |
| 44 |
Register an old-style (a.k.a. `S3') class as a formally defined
|
44 |
Register an old-style (a.k.a. `S3') class as a formally defined
|
| 45 |
class. The \code{Classes} argument is the character vector used as the
|
45 |
class. The \code{Classes} argument is the character vector used as the
|
| 46 |
\code{class} attribute; in particular, if there is more than one
|
46 |
\code{class} attribute; in particular, if there is more than one
|
| 47 |
string, old-style class inheritance is mimiced. Registering via
|
47 |
string, old-style class inheritance is mimiced. Registering via
|
| 48 |
\code{setOldClass} allows S3 classes to appear in method
|
48 |
\code{setOldClass} allows S3 classes to appear in method
|
| 49 |
signatures, and in class inheritance if a prototype is included.
|
49 |
signatures, and as a slot in an S4 class if a prototype is included.
|
| 50 |
}
|
50 |
}
|
| 51 |
\usage{
|
51 |
\usage{
|
| 52 |
setOldClass(Classes, prototype, where, test = FALSE)
|
52 |
setOldClass(Classes, prototype, where, test = FALSE)
|
| 53 |
}
|
53 |
}
|
| 54 |
\arguments{
|
54 |
\arguments{
|
| Line 56... |
Line 56... |
| 56 |
A character vector, giving the names for old-style
|
56 |
A character vector, giving the names for old-style
|
| 57 |
classes, as they would appear on the right side of an assignment of
|
57 |
classes, as they would appear on the right side of an assignment of
|
| 58 |
the \code{class} attribute.
|
58 |
the \code{class} attribute.
|
| 59 |
}
|
59 |
}
|
| 60 |
\item{prototype}{
|
60 |
\item{prototype}{
|
| 61 |
An optional object to use as the prototype. This should be provided as the default S3 object for the class, if you plan to use the class as a slot or superclass in an S4 class. See the details section.
|
61 |
An optional object to use as the prototype. This should be provided as the default S3 object for the class, if you plan to use the class as a slot in an S4 class. See the details section.
|
| 62 |
}
|
62 |
}
|
| 63 |
\item{where}{
|
63 |
\item{where}{
|
| 64 |
Where to store the class definitions, the global or top-level
|
64 |
Where to store the class definitions, the global or top-level
|
| 65 |
environment by default. (When either function is called in the
|
65 |
environment by default. (When either function is called in the
|
| 66 |
source for a package, the class definitions will be included in the
|
66 |
source for a package, the class definitions will be included in the
|
| Line 76... |
Line 76... |
| 76 |
Each of the names will be defined as an S4 class, extending the
|
76 |
Each of the names will be defined as an S4 class, extending the
|
| 77 |
remaining classes in \code{Classes}, and the class
|
77 |
remaining classes in \code{Classes}, and the class
|
| 78 |
\code{oldClass}, which is the \dQuote{root} of all old-style classes.
|
78 |
\code{oldClass}, which is the \dQuote{root} of all old-style classes.
|
| 79 |
S3 classes have no formal definition, and therefore no formally defined slots.
|
79 |
S3 classes have no formal definition, and therefore no formally defined slots.
|
| 80 |
If a \code{prototype} argument is supplied in the call to \code{setOldClass()}, objects from the class can be generated.
|
80 |
If a \code{prototype} argument is supplied in the call to \code{setOldClass()}, objects from the class can be generated.
|
| 81 |
If the S3 class is to be extended by an S4 class or a slot in an S4 class, providing a prototype is recommended.
|
81 |
If the S3 class is to be a slot in an S4 class, providing a prototype is recommended.
|
| 82 |
Otherwise, the class will be created as a virtual S4 class; method dispatch will still work and inheritance will follow the S3 class hierarchy, but actions that require a prototype object from the class will not.
|
82 |
Otherwise, the class will be created as a virtual S4 class; method dispatch will still work and inheritance will follow the S3 class hierarchy, but actions that require a prototype object from the class will not.
|
| 83 |
For example, using the class as a slot in an S4 class definition will set the corresponding slot to \code{NULL} in the prototype for the S4 class.
|
83 |
For example, using the class as a slot in an S4 class definition will set the corresponding slot to \code{NULL} in the prototype for the S4 class.
|
| 84 |
|
84 |
|
| 85 |
Providing a prototype allows the function \code{new()} to be called for this class, but optional arguments in this call are not meaningful, since the class has no formal slots.
|
85 |
Providing a prototype allows the function \code{new()} to be called for this class, but optional arguments in this call are not meaningful, since the class has no formal slots.
|
| 86 |
Extending an S3 class with an S4 class is formally legal, but discouraged.
|
86 |
Extending an S3 class with an S4 class is formally legal, but discouraged.
|