| Line 108... |
Line 108... |
| 108 |
first argument and nothing else.
|
108 |
first argument and nothing else.
|
| 109 |
In this case,
|
109 |
In this case,
|
| 110 |
the recommended approach is to define the S3 method and also supply the
|
110 |
the recommended approach is to define the S3 method and also supply the
|
| 111 |
identical function as the definition of the S4 method.
|
111 |
identical function as the definition of the S4 method.
|
| 112 |
If the S3 generic function was \code{f3(x, ...)} and the S4 class for
|
112 |
If the S3 generic function was \code{f3(x, ...)} and the S4 class for
|
| 113 |
the new method was
|
113 |
the new method was
|
| 114 |
\code{"myClass"}:
|
114 |
\code{"myClass"}:
|
| 115 |
|
115 |
|
| 116 |
\code{f3.myClass <- function(x, ...) { ..... }}
|
116 |
\code{f3.myClass <- function(x, ...) { ..... }}
|
| 117 |
|
117 |
|
| 118 |
\code{setMethod("f3", "myClass", f3.myClass)}
|
118 |
\code{setMethod("f3", "myClass", f3.myClass)}
|
| Line 231... |
Line 231... |
| 231 |
Two additional mechanisms for defining
|
231 |
Two additional mechanisms for defining
|
| 232 |
superclasses exist.
|
232 |
superclasses exist.
|
| 233 |
A call to \code{\link{setClassUnion}} creates a union class that
|
233 |
A call to \code{\link{setClassUnion}} creates a union class that
|
| 234 |
is a
|
234 |
is a
|
| 235 |
superclass of each of the members of the union.
|
235 |
superclass of each of the members of the union.
|
| 236 |
A call to
|
236 |
A call to
|
| 237 |
\code{\link{setIs}} can create an inheritance relationship that is not the simple one of
|
237 |
\code{\link{setIs}} can create an inheritance relationship that is not the simple one of
|
| 238 |
containing the superclass representation in the new class.
|
238 |
containing the superclass representation in the new class.
|
| 239 |
Arguments \code{coerce} and \code{replace} supply methods to convert
|
239 |
Arguments \code{coerce} and \code{replace} supply methods to convert
|
| 240 |
to the superclass and to replace the part corresponding to the superclass.
|
240 |
to the superclass and to replace the part corresponding to the superclass.
|
| 241 |
(In addition, a \code{test=} argument allows conditional inheritance; conditional inheritance is not
|
241 |
(In addition, a \code{test=} argument allows conditional inheritance; conditional inheritance is not
|
| Line 342... |
Line 342... |
| 342 |
|
342 |
|
| 343 |
A call to a generic function therefore has two contexts: one for the
|
343 |
A call to a generic function therefore has two contexts: one for the
|
| 344 |
function and a second for the method.
|
344 |
function and a second for the method.
|
| 345 |
The argument objects will be copied to the second context, but not any
|
345 |
The argument objects will be copied to the second context, but not any
|
| 346 |
local objects created in a nonstandard generic function.
|
346 |
local objects created in a nonstandard generic function.
|
| 347 |
The other important distinction is that the parent
|
347 |
The other important distinction is that the parent
|
| 348 |
(\dQuote{enclosing}) environment of the second context is the environment
|
348 |
(\dQuote{enclosing}) environment of the second context is the environment
|
| 349 |
of the method as a function, so that all \R programming techniques
|
349 |
of the method as a function, so that all \R programming techniques
|
| 350 |
using such environments apply to method definitions as ordinary functions.
|
350 |
using such environments apply to method definitions as ordinary functions.
|
| 351 |
|
351 |
|
| 352 |
|
352 |
|
| Line 501... |
Line 501... |
| 501 |
## a method explicitly for "myFrame" class
|
501 |
## a method explicitly for "myFrame" class
|
| 502 |
|
502 |
|
| 503 |
|
503 |
|
| 504 |
setMethod("[",
|
504 |
setMethod("[",
|
| 505 |
signature(x = "myFrame"),
|
505 |
signature(x = "myFrame"),
|
| 506 |
function (x, i, j, ..., drop = TRUE)
|
506 |
function (x, i, j, ..., drop = TRUE)
|
| 507 |
{
|
507 |
{
|
| 508 |
S3Part(x) <- callNextMethod()
|
508 |
S3Part(x) <- callNextMethod()
|
| 509 |
x@timestamps <- c(Sys.time(), as.POSIXct(x@timestamps))
|
509 |
x@timestamps <- c(Sys.time(), as.POSIXct(x@timestamps))
|
| 510 |
x
|
510 |
x
|
| 511 |
}
|
511 |
}
|