Information on intervals in which times fall
get_intervals(x, times, ...)
# S3 method for default
get_intervals(x, times, left.open = TRUE, rightmost.closed = TRUE, ...)
An object from which interval information can be obtained,
see int_info
.
A vector of times for which corresponding interval information should be returned.
Further arguments passed to findInterval
.
logical; if true all the intervals are open at left
and closed at right; in the formulas below, \(\le\) should be
swapped with \(<\) (and \(>\) with \(\ge\)), and
rightmost.closed
means ‘leftmost is closed’. This may
be useful, e.g., in survival analysis computations.
logical; if true, the rightmost interval,
vec[N-1] .. vec[N]
is treated as closed, see below.
A data.frame
containing information on intervals in which
values of times
fall.
set.seed(111018)
brks <- c(0, 4.5, 5, 10, 30)
int_info(brks)
#> tstart tend intlen intmid interval
#> 1 0.0 4.5 4.5 2.25 (0,4.5]
#> 2 4.5 5.0 0.5 4.75 (4.5,5]
#> 3 5.0 10.0 5.0 7.50 (5,10]
#> 4 10.0 30.0 20.0 20.00 (10,30]
x <- runif (3, 0, 30)
x
#> [1] 23.240596 22.575389 3.691534
get_intervals(brks, x)
#> times tstart tend intlen intmid interval
#> 1 23.240596 10 30.0 20.0 20.00 (10,30]
#> 2 22.575389 10 30.0 20.0 20.00 (10,30]
#> 3 3.691534 0 4.5 4.5 2.25 (0,4.5]