| Line 4... |
Line 4... |
| 4 |
\alias{NextMethod}
|
4 |
\alias{NextMethod}
|
| 5 |
\alias{S3Methods}
|
5 |
\alias{S3Methods}
|
| 6 |
\alias{.isMethodsDispatchOn}
|
6 |
\alias{.isMethodsDispatchOn}
|
| 7 |
\description{
|
7 |
\description{
|
| 8 |
\R possesses a simple generic function mechanism which can be used for
|
8 |
\R possesses a simple generic function mechanism which can be used for
|
| 9 |
an object-oriented style of programming. Method despatch takes place
|
9 |
an object-oriented style of programming. Method dispatch takes place
|
| 10 |
based on the class of the first argument to the generic function or on
|
10 |
based on the class of the first argument to the generic function or on
|
| 11 |
the object supplied as an argument to \code{UseMethod} or \code{NextMethod}.
|
11 |
the object supplied as an argument to \code{UseMethod} or \code{NextMethod}.
|
| 12 |
}
|
12 |
}
|
| 13 |
\usage{
|
13 |
\usage{
|
| 14 |
UseMethod(generic, object)
|
14 |
UseMethod(generic, object)
|
| Line 26... |
Line 26... |
| 26 |
A class attribute is a character vector giving the names of
|
26 |
A class attribute is a character vector giving the names of
|
| 27 |
the classes which the object \dQuote{inherits} from.
|
27 |
the classes which the object \dQuote{inherits} from.
|
| 28 |
If the object does not have a class attribute, it has an implicit
|
28 |
If the object does not have a class attribute, it has an implicit
|
| 29 |
class. Matrices and arrays have class \code{"matrix"}
|
29 |
class. Matrices and arrays have class \code{"matrix"}
|
| 30 |
or\code{"array"} followed by the class of the underlying vector.
|
30 |
or\code{"array"} followed by the class of the underlying vector.
|
| 31 |
Most vectors have class the result of \code{\link{mode}(x)}, expect
|
31 |
Most vectors have class the result of \code{\link{mode}(x)}, except
|
| 32 |
that integer vectors have class \code{c("integer", "numeric")} and
|
32 |
that integer vectors have class \code{c("integer", "numeric")} and
|
| 33 |
real vectors have class \code{c("double", "numeric")}.
|
33 |
real vectors have class \code{c("double", "numeric")}.
|
| 34 |
|
34 |
|
| 35 |
When a generic function \code{fun} is applied to an object with class
|
35 |
When a generic function \code{fun} is applies to an object with class
|
| 36 |
attribute \code{c("first", "second")}, the system searches for a
|
36 |
attribute \code{c("first", "second")}, the system searches for a
|
| 37 |
function called \code{fun.first} and, if it finds it, applied it to
|
37 |
function called \code{fun.first} and, if it finds it, applied it to
|
| 38 |
the object. If no such function is found a function called
|
38 |
the object. If no such function is found a function called
|
| 39 |
\code{fun.second} is tried. If no class name produces a suitable
|
39 |
\code{fun.second} is tried. If no class name produces a suitable
|
| 40 |
function, the function \code{fun.default} is used, if it exists, or an
|
40 |
function, the function \code{fun.default} is used, if it exists, or an
|