Create a table of time intervals given a vector or data frame of unique times. This would typically be passed to id_attributes.
time_intervals(times)
Either a vector of starting times for each interval or a
data.frame
with at least one column named time_start
.
An object of class time_intervals
that inherits from
data.table
in the same format as time_intervals
as
described in id_attributes.
time_intervals(c(0, 3, 5))
#> time_id time_start time_stop
#> <int> <num> <num>
#> 1: 1 0 3
#> 2: 2 3 5
#> 3: 3 5 Inf
time_intervals(data.frame(time_start = c(0, 3, 5),
time_cat = c("Time <= 3", "3 < Time <= 5",
"Time > 5")))
#> time_id time_start time_cat time_stop
#> <int> <num> <char> <num>
#> 1: 1 0 Time <= 3 3
#> 2: 2 3 3 < Time <= 5 5
#> 3: 3 5 Time > 5 Inf