brk_manual {santoku} | R Documentation |
Create a breaks
object manually
Description
Create a breaks
object manually
Usage
brk_manual(breaks, left_vec)
Arguments
breaks |
A vector, which must be sorted. |
left_vec |
A logical vector, the same length as |
Details
All breaks must be closed on exactly one side, like ..., x) [x, ...
(left-closed) or ..., x) [x, ...
(right-closed).
For example, if breaks = 1:3
and left = c(TRUE, FALSE, TRUE)
, then the
resulting intervals are
T F T [ 1, 2 ] ( 2, 3 )
Singleton breaks are created by repeating a number in breaks
. Singletons
must be closed on both sides, so if there is a repeated number
at indices i
, i+1
, left[i]
must be TRUE
and left[i+1]
must be
FALSE
.
Value
A function which returns an object of class breaks
.
Examples
lbrks <- brk_manual(1:3, rep(TRUE, 3))
chop(1:3, lbrks, extend = FALSE)
rbrks <- brk_manual(1:3, rep(FALSE, 3))
chop(1:3, rbrks, extend = FALSE)
brks_singleton <- brk_manual(
c(1, 2, 2, 3),
c(TRUE, TRUE, FALSE, TRUE))
chop(1:3, brks_singleton, extend = FALSE)
[Package santoku version 1.0.0 Index]