Debian Codegraph @

man/Intervals-class.Rd

raw
1 \name{Intervals-class}
2
3 \docType{class}
4
5 \alias{Intervals}
6 \alias{Intervals_full}
7
8 \alias{Intervals-class}
9 \alias{Intervals_full-class}
10
11 \alias{[,Intervals-method}
12 \alias{[,Intervals_full-method}
13 \alias{[<-,Intervals,ANY,missing,Intervals_virtual-method}
14 \alias{[<-,Intervals_full,ANY,missing,Intervals_virtual-method}
15 \alias{closed<-}
16 \alias{closed<-,Intervals-method}
17 \alias{closed<-,Intervals_full-method}
18 \alias{coerce,Intervals,Intervals_full-method}
19 \alias{coerce,Intervals_full,Intervals-method}
20 \alias{initialize,Intervals-method}
21 \alias{initialize,Intervals_full-method}
22
23
24
25
26 \title{Classes "Intervals" and "Intervals_full"}
27
28 \description{
29 \code{"Intervals"} objects are two-column matrices which represent
30 sets, possibly non-disjoint and in no particular order, of intervals
31 on either the integers or the real line. All intervals in each object
32 have the same endpoint closure pattern. \code{"Intervals_full"}
33 objects are similar, but permit interval-by-interval endpoint closure
34 specification.
35 }
36
37 \section{Objects from the Class}{
38 Objects can be created by calls of the form \code{new("Intervals",
39 \dots)}, or better, by using the constructor functions
40 \code{\link{Intervals}(\dots)} and
41 \code{\link{Intervals_full}(\dots)}.
42 }
43
44 \section{Slots}{
45
46 \describe{
47
48 \item{\code{.Data}:}{See \code{"\linkS4class{Intervals_virtual}"}.}
49
50 \item{\code{closed}:}{
51 For \code{"Intervals"} objects, a two-element logical vector. For
52 \code{"Intervals_full"} objects, a two-column logical matrix with
53 the same dimensions as \code{.Data}. If omitted in a \code{new}
54 call, the \code{closed} slot will be initialized to an object of
55 appropriate type and size, with all entries \code{TRUE}. If
56 \code{closed} is a vector of length 1, or a vector of length 2 for
57 the \code{"Intervals_full"} class, an appropriate object will be
58 made by reusing the supplied values row-wise. See the example
59 below.
60 }
61
62 \item{\code{type}:}{See \code{"\linkS4class{Intervals_virtual}"}.}
63
64 }
65
66 }
67
68 \section{Extends}{
69
70 Class \code{"\linkS4class{Intervals_virtual}"}, directly.
71
72 Class \code{"\linkS4class{matrix}"}, by class
73 \code{"Intervals_virtual"}, distance 2.
74
75 Class \code{"\linkS4class{array}"}, by class
76 \code{"Intervals_virtual"}, distance 3.
77
78 Class \code{"\linkS4class{structure}"}, by class
79 \code{"Intervals_virtual"}, distance 4.
80
81 Class \code{"\linkS4class{vector}"}, by class
82 \code{"Intervals_virtual"}, distance 5, with explicit coerce.
83
84 }
85
86 \seealso{
87 See \code{"\linkS4class{Intervals_virtual}"}.
88 }
89
90 \section{S3 methods}{
91
92 As of R 2.8.1, it still does not seem possible to write S4 methods for
93 \code{rbind} or \code{c}. To concatenate sets of intervals into a
94 single sets, the S3 methods \code{\link{c.Intervals}} and
95 \code{\link{c.Intervals_full}} are provided. While \code{rbind} might
96 seem more natural, its S3 dispatch is non-standard and it could not be
97 used. Both methods are documented separately.
98
99 }
100
101 \section{S4 methods}{
102
103 \describe{
104
105 \item{[}{\code{ signature(x = "Intervals")} }
106 \item{[}{\code{ signature(x = "Intervals_full")} }
107 \item{[<-}{\code{ signature(x = "Intervals", i = "ANY", j = "missing", value = "Intervals_virtual")} }
108 \item{[<-}{\code{ signature(x = "Intervals_full", i = "ANY", j = "missing", value = "Intervals_virtual")} }
109 \item{adjust_closure}{\code{ signature(x = "Intervals")} }
110 \item{adjust_closure}{\code{ signature(x = "Intervals_full")} }
111 \item{closed<-}{\code{ signature(x = "Intervals")} }
112 \item{closed<-}{\code{ signature(x = "Intervals_full")} }
113 \item{coerce}{\code{ signature(from = "Intervals", to = "Intervals_full")} }
114 \item{coerce}{\code{ signature(from = "Intervals_full", to = "Intervals")} }
115 \item{empty}{\code{ signature(x = "Intervals")} }
116 \item{empty}{\code{ signature(x = "Intervals_full")} }
117 \item{initialize}{\code{ signature(.Object = "Intervals")} }
118 \item{initialize}{\code{ signature(.Object = "Intervals_full")} }
119 \item{size}{\code{ signature(x = "Intervals")} }
120 \item{size}{\code{ signature(x = "Intervals_full")} }
121
122 % \item{\code{[}:}{
123 % When used to subset rows, class is preserved; when used to subset
124 % columns, the \code{closed} and \code{type} slots are discarded and
125 % an appropriately subset version of \code{.Data} is returned. See
126 % example below.
127 % }
128 %
129 % \item{\code{closed<-}:}{
130 % Replacement accessor for \code{closed} slot. See the example
131 % below. See description of the \code{closed} slot above for details
132 % on how one- or two-element logical vectors are interpreted.
133 % }
134 %
135 % \item{\code{coerce}:}{
136 % Coercion methods are provided for converting back and forth
137 % between \code{"Intervals"} and \code{"Intervals_full"}
138 % objects. See example below. An error will be generated when
139 % attemption to down-class a \code{"Intervals_full"} object which
140 % does not have the same closure settings for every interval.
141 %
142 % A coercion method is also provided for pretty character strings.
143 % }
144
145 }
146
147 }
148
149 \note{
150 We do not currently permit an integer data type for the endpoints
151 matrix, even when \code{type == "Z"}, because this creates
152 complications when taking complements -- which is most easily handled
153 through the use of \code{-Inf} and \code{Inf}. This is particularly
154 awkward for objects of class \code{"Intervals"}, since current endpoint
155 closure settings may not permit inclusion of the minimal/maximal
156 integer. This issue may be addressed, however, in future updates. (We
157 do, however, check that endpoints are congruent to 0 mod 1 when
158 \code{type == "Z"}.)
159
160 When creating object, non-matrix endpoint sources will be converted to
161 a two-column matrix, for convenience. Recycling is supported for the
162 \code{closed} slot when creating new objects.
163 }
164
165 \section{Warning}{
166 Validity checking takes place when, for example, using the
167 \code{type<-} replacement accessor: if one attempts to set type to
168 \code{"Z"} but the endpoint matrix contains non-integer values, an
169 error is generated. Because accessors are not used for the endpoint
170 matrix itself, though, it is possible to create invalid \code{"Z"}
171 objects by setting endpoints to inappropriate values.
172 }
173
174 \examples{
175
176 # The "Intervals" class
177
178 i <- Intervals(
179 matrix(
180 c(1,2,
181 3,5,
182 4,6,
183 8,9
184 ),
185 byrow = TRUE,
186 ncol = 2
187 ),
188 closed = c( TRUE, TRUE ),
189 type = "Z"
190 )
191
192 # Row subsetting preserves class. Column subsetting causes coercion to
193 # "matrix" class.
194
195 i
196 i[1:2,]
197 i[,1:2]
198
199 # Full endpoint control
200
201 j <- as( i, "Intervals_full" )
202 closed(j)[ 3:4, 2 ] <- FALSE
203 closed(j)[ 4, 1 ] <- FALSE
204 j
205
206 # Rownames may be used
207
208 rownames(j) <- c( "apple", "banana", "cherry", "date" )
209 j
210
211 # Assignment preserves class, coercing if necessary
212
213 j[2:3] <- i[1:2,]
214 j
215
216 }
217
218 \keyword{classes}