Pad the datetime variable after thicken_cust
is applied, using the same
spanning.
pad_cust(x, spanned, by = NULL, group = NULL, drop_last_spanned = TRUE)
x | A data frame containing at least one datetime variable of
class |
---|---|
spanned | A datetime vector to which the the datetime variable in
|
by | Only needs to be specified when |
group | Optional character vector that specifies the grouping variable(s). Padding will take place within the different group values. |
drop_last_spanned | Logical, indicating whether to drop the last value
from |
The data frame x
with the datetime column padded.
library(dplyr) # analysis of traffic accidents in traffic jam hours and other hours. accidents <- emergency %>% filter(title == "Traffic: VEHICLE ACCIDENT -") spanning <- span_time("20151210 16", "20161017 17", tz = "EST") %>% subset_span(list(hour = c(6, 9, 16, 19))) thicken_cust(accidents, spanning, "period") %>% count(period) %>% pad_cust(spanning)#> # A tibble: 1,248 x 2 #> period n #> <dttm> <int> #> 1 2015-12-10 16:00:00 18 #> 2 2015-12-10 19:00:00 11 #> 3 2015-12-11 06:00:00 15 #> 4 2015-12-11 09:00:00 28 #> 5 2015-12-11 16:00:00 24 #> 6 2015-12-11 19:00:00 32 #> 7 2015-12-12 06:00:00 3 #> 8 2015-12-12 09:00:00 52 #> 9 2015-12-12 16:00:00 17 #> 10 2015-12-12 19:00:00 28 #> # … with 1,238 more rows