| Line 31... |
Line 31... |
| 31 |
class \code{from} to class \code{to}. The methods will then be used
|
31 |
class \code{from} to class \code{to}. The methods will then be used
|
| 32 |
by calls to \code{\link{as}} for objects with class \code{from},
|
32 |
by calls to \code{\link{as}} for objects with class \code{from},
|
| 33 |
including calls that replace part of the object.
|
33 |
including calls that replace part of the object.
|
| 34 |
|
34 |
|
| 35 |
Methods for this purpose work indirectly, by defining methods for
|
35 |
Methods for this purpose work indirectly, by defining methods for
|
| 36 |
function \code{coerce}. This function is \emph{not} to be called
|
36 |
function \code{coerce}. The \code{coerce} function is \emph{not} to
|
| 37 |
directly, and method selection uses class inheritance only on the
|
37 |
be called directly, and method selection uses class inheritance only
|
| 38 |
first argument.
|
38 |
on the first argument.
|
| 39 |
}
|
39 |
}
|
| 40 |
\usage{
|
40 |
\usage{
|
| 41 |
|
- |
|
| 42 |
setAs(from, to, def, replace, where = topenv(parent.frame()))
|
41 |
setAs(from, to, def, replace, where = topenv(parent.frame()))
|
| 43 |
|
- |
|
| 44 |
}
|
42 |
}
|
| 45 |
|
- |
|
| 46 |
\arguments{
|
43 |
\arguments{
|
| 47 |
|
- |
|
| 48 |
\item{from, to}{The classes between which the coerce methods
|
44 |
\item{from, to}{The classes between which the coerce methods
|
| 49 |
\code{def} and \code{replace} perform coercion.
|
45 |
\code{def} and \code{replace} perform coercion.
|
| 50 |
}
|
46 |
}
|
| 51 |
\item{def}{function of one argument. It will get an object from
|
47 |
\item{def}{function of one argument. It will get an object from
|
| 52 |
class \code{from} and had better return an object of class
|
48 |
class \code{from} and had better return an object of class
|
| 53 |
\code{to}. The convention is that
|
49 |
\code{to}. The convention is that
|
| 54 |
the name of the argument is \code{from}; if another argument name
|
50 |
the name of the argument is \code{from}; if another argument name
|
| 55 |
is used, \code{setAs} will attempt to substitute \code{from}. }
|
51 |
is used, \code{setAs} will attempt to substitute \code{from}. }
|
| 56 |
\item{replace}{if supplied, the function to use as a replacement
|
52 |
\item{replace}{if supplied, the function to use as a replacement
|
| 57 |
method, when \code{as} is used on the left of an assignment.
|
53 |
method, when \code{as} is used on the left of an assignment.
|
| 58 |
Should be a function of two arguments, \code{from, value},
|
54 |
Should be a function of two arguments, \code{from, value},
|
| 59 |
although \code{setAs} will attempt to substitute if the arguments
|
55 |
although \code{setAs} will attempt to substitute if the arguments
|
| 60 |
differ.
|
56 |
differ.
|
| 61 |
|
57 |
|
| 62 |
\emph{The remaining argument will not be used in standard applications.}
|
58 |
\emph{The remaining argument will not be used in standard applications.}
|
| 63 |
}
|
59 |
}
|
| 64 |
|
60 |
|
| 65 |
\item{where}{the position or environment in which to store the
|
61 |
\item{where}{the position or environment in which to store the
|
| 66 |
resulting methods. Do not use this argument when defining a method
|
62 |
resulting methods. Do not use this argument when defining a method
|
| 67 |
in a package. Only the default, the namespace of the package,
|
63 |
in a package. Only the default, the namespace of the package,
|