The XIntegerViews class is the basic container for storing a set of views (start/end locations) on the same XInteger object.
An XIntegerViews object contains a set of views (start/end locations) on the
same XInteger object called "the subject integer vector" or simply
Each view is defined by its start and end locations: both are integers such
that start <= end.
An XIntegerViews object is in fact a particular case of a
Views object (the XIntegerViews class contains the
Views class) so it can be manipulated in a similar manner:
?Views for more information.
Note that two views can overlap and that a view can be "out of limits"
i.e. it can start before the first element of the subject or/and end
after its last element.
In the code snippets below,
e2 are XIntegerViews objects,
i can be a numeric or logical vector.
Extract a view as an XInteger object.
i must be a single numeric value (a numeric vector of length 1).
Can't be used for extracting a view that is "out of limits" (raise an
error). The returned object has the same XInteger subtype as
e1 == e2:
A vector of logicals indicating the result of the view by
view comparison. The views in the shorter of the two XIntegerViews
object being compared are recycled as necessary.
e1 != e2:
!(e1 == e2).
view-summarization-methods, Views-class, XInteger-class, XDoubleViews-class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
## One standard way to create an XIntegerViews object is to use ## the Views() constructor: subject <- as(c(45, 67, 84, 67, 45, 78), "XInteger") v4 <- Views(subject, start=3:0, end=5:8) v4 subject(v4) length(v4) start(v4) end(v4) width(v4) ## Attach a comment to views #3 and #4: names(v4)[3:4] <- "out of limits" names(v4) ## A more programatical way to "tag" the "out of limits" views: idx <- start(v4) < 1 | end(v4) > length(subject(v4)) names(v4)[idx] <- "out of limits" ## Extract a view as an XInteger object: v4[] ## It is an error to try to extract an "out of limits" view: ## Not run: v4[] # Error! ## End(Not run) ## Here the first view doesn't even overlap with the subject: subject <- as(c(97, 97, 97, 45, 45, 98), "XInteger") Views(subject, start=-3:4, end=-3:4 + c(3:6, 6:3)) ## Views on a big XInteger subject: subject <- XInteger(99999, sample(99, 99999, replace=TRUE) - 50) v5 <- Views(subject, start=1:99*1000, end=1:99*1001) v5 v5[-1] v5[] ## 31 adjacent views: successiveViews(subject, 40:10)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.