The R Project SVN R

Rev

Rev 42839 | Rev 45824 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 42839 Rev 45653
Line 17... Line 17...
17
\alias{Ops,structure,structure-method}
17
\alias{Ops,structure,structure-method}
18
\alias{Ops,structure,array-method}
18
\alias{Ops,structure,array-method}
19
\alias{Ops,vector,structure-method}
19
\alias{Ops,vector,structure-method}
20
\alias{Ops,array,structure-method}
20
\alias{Ops,array,structure-method}
21
\alias{Ops,array,array-method}
21
\alias{Ops,array,array-method}
-
 
22
\alias{initialize,array-method}
-
 
23
\alias{initialize,matrix-method}
-
 
24
\alias{initialize,ts-method}
-
 
25
\alias{show,ts-method}
22
%
26
%
23
\description{
27
\description{
24
  The virtual class \code{structure} and classes that
28
  The virtual class \code{structure} and classes that
25
  extend it are formal classes analogous to S language structures such
29
  extend it are formal classes analogous to S language structures such
26
  as arrays and time-series.
30
  as arrays and time-series.
Line 43... Line 47...
43
  arguments to the corresponding function, e.g., to function
47
  arguments to the corresponding function, e.g., to function
44
  \code{matrix()}.  There is no particular advantage over calling those
48
  \code{matrix()}.  There is no particular advantage over calling those
45
  functions directly, unless you are writing software designed to work
49
  functions directly, unless you are writing software designed to work
46
  for multiple classes, perhaps with the class name and the arguments
50
  for multiple classes, perhaps with the class name and the arguments
47
  passed in.
51
  passed in.
-
 
52
 
-
 
53
  Objects created from the classes \code{"matrix"} and \code{"array"} are unusual, to put
-
 
54
  it mildly, and have been for some time.  Although they may appear to
-
 
55
  be objects from these classes, they do not have the internal
-
 
56
  structure of either an S3 or S4 class object.  In particular, they
-
 
57
  have no \code{"class"} attribute and are not recognized as objects
-
 
58
  with classes (that is, both \code{\link{is.object}} and
-
 
59
  \code{\link{isS4}} will return \code{FALSE} for such objects).
-
 
60
 
-
 
61
  That the objects still behave as if they came from the corresponding
-
 
62
  class (most of the time, anyway) results from special code
-
 
63
  recognizing such objects being built into the base code of \R.
-
 
64
  For most purposes, treating the classes in the usual way will work,
-
 
65
  fortunately.  One consequence of the special treatment is that these
-
 
66
  two classes\emph{may} be used as the data part of an S4 class; for
-
 
67
  example, you can get away with \code{contains = "matrix"} in a call
-
 
68
  to \code{\link{setGeneric}} to create an S4 class that is a subclass
-
 
69
  of \code{"matrix"}.  There is no guarantee that everything will work
-
 
70
  perfectly, but a number of classes have been written in this form
-
 
71
  successfully.
-
 
72
 
-
 
73
  The class \code{"ts"}  is basically an S3 class
-
 
74
  that has been registered with S4, using the
-
 
75
  \code{\link{setOldClass}} mechanism.  Versions of \R through 2.7.0
-
 
76
  treated this class as a pure S4 class, which was in principal a good
-
 
77
  idea, but in practice did not allow subclasses to be defined and had
-
 
78
  other intrinsic problems.  (For example, setting the
-
 
79
  \code{"tsp"} parameters as a slot often fails because the built-in
-
 
80
  implementation does not allow the slot to be temporarily
-
 
81
  inconsistent with the length of the data. Also, the S4 class
-
 
82
  prevented the correct specification of the S3 inheritance for class
-
 
83
  \code{"mts"}.)
-
 
84
 
-
 
85
  The current behavior (beginning with version 2.8.0 of \R) registers
-
 
86
  \code{"ts"} as an S3 class, but also provides some methods that at
-
 
87
  least partially support classes that contain \code{"ts"}.  The S3
-
 
88
  inheritance of \code{"mts"} in package \code{stats} is also registered.
48
}
89
}
49
\section{Extends}{
90
\section{Extends}{
50
  The specific classes all extend class \code{"structure"}, directly, and
91
  The specific classes all extend class \code{"structure"}, directly, and
51
  class \code{"vector"}, by class \code{"structure"}.
92
  class \code{"vector"}, by class \code{"structure"}.
52
}
93
}
Line 61... Line 102...
61
      vector structures as in the reference.
102
      vector structures as in the reference.
62
    }
103
    }
63
  }
104
  }
64
}
105
}
65
\references{
106
\references{
-
 
107
 Chambers, John M. (2008)
-
 
108
 \emph{Software for Data Analysis: Programming with R}
-
 
109
  Springer.  (For the R version.)
-
 
110
 
-
 
111
 Chambers, John M. (1998)
-
 
112
 \emph{Programming with Data}
-
 
113
 Springer (For the original S4 version.)
-
 
114
 
66
  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
115
  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
67
  \emph{The New S Language}.
116
  \emph{The New S Language}.
68
  Wadsworth \& Brooks/Cole.
117
  Wadsworth \& Brooks/Cole (for the original vector structures).
69
}
118
}
70
\examples{
119
\examples{
71
showClass("structure")
120
showClass("structure")
72
 
121
 
73
## explore a bit :
122
## explore a bit :