| 60325 |
ripley |
1 |
% File src/library/methods/man/nonStructure-class.Rd
|
| 68948 |
ripley |
2 |
% Part of the R package, https://www.R-project.org
|
| 60325 |
ripley |
3 |
% Copyright 2009-12 R Core Team
|
|
|
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
| 48062 |
jmc |
6 |
\name{nonStructure-class}
|
|
|
7 |
\docType{class}
|
| 56186 |
murdoch |
8 |
\alias{nonStructure-class}
|
| 48062 |
jmc |
9 |
\alias{Math,nonStructure-method}
|
|
|
10 |
\alias{Math2,nonStructure-method}
|
|
|
11 |
\alias{Ops,vector,nonStructure-method}
|
|
|
12 |
\alias{Ops,nonStructure,vector-method}
|
|
|
13 |
\alias{Ops,nonStructure,nonStructure-method}
|
|
|
14 |
|
|
|
15 |
\title{A non-structure S4 Class for basic types }
|
|
|
16 |
\description{ S4 classes that are defined to extend one of the basic
|
|
|
17 |
vector classes should contain the class
|
|
|
18 |
\code{\linkS4class{structure}} if they behave like structures; that
|
|
|
19 |
is, if they should retain their class behavior under math functions
|
|
|
20 |
or operators, so long as their length is unchanged.
|
|
|
21 |
On the other hand, if their class depends on the values in the
|
|
|
22 |
object, not just its structure, then they should lose that class
|
|
|
23 |
under any such transformations. In the latter case, they should be
|
|
|
24 |
defined to contain \code{nonStructure}.
|
|
|
25 |
|
|
|
26 |
If neither of these strategies applies, the class likely needs some
|
| 48826 |
hornik |
27 |
methods of its own for \code{\link{Ops}}, \code{\link{Math}}, and/or
|
| 48062 |
jmc |
28 |
other generic functions. What is not usually a good idea is to allow
|
|
|
29 |
such computations to drop down to the default, base code. This is
|
|
|
30 |
inconsistent with most definitions of such classes.}
|
|
|
31 |
|
|
|
32 |
\section{Methods}{
|
|
|
33 |
Methods are defined for operators and math functions (groups
|
| 74363 |
maechler |
34 |
\code{\link{Ops}}, \code{\link{Math}} and \code{\link{Math2}}). In
|
| 48062 |
jmc |
35 |
all cases the result is an ordinary vector of the appropriate type.
|
|
|
36 |
}
|
|
|
37 |
\references{
|
|
|
38 |
Chambers, John M. (2008)
|
|
|
39 |
\emph{Software for Data Analysis: Programming with R}
|
|
|
40 |
Springer.
|
|
|
41 |
}
|
|
|
42 |
\seealso{
|
| 49972 |
ripley |
43 |
\code{\linkS4class{structure}}
|
| 48062 |
jmc |
44 |
}
|
|
|
45 |
\examples{
|
|
|
46 |
setClass("NumericNotStructure", contains = c("numeric","nonStructure"))
|
|
|
47 |
xx <- new("NumericNotStructure", 1:10)
|
|
|
48 |
xx + 1 # vector
|
|
|
49 |
log(xx) # vector
|
|
|
50 |
sample(xx) # vector
|
|
|
51 |
\dontshow{removeClass("NumericNotStructure")
|
|
|
52 |
}
|
|
|
53 |
}
|
|
|
54 |
\keyword{classes}
|