on_event()
defines an alternative date to use as an event if event
occurs. It is usually useful as a way to deviate from a normal schedule in
the case of an unusual circumstance.
on_event(x, event, jump)
x |
An event defining normal behavior. |
---|---|
event |
An event defining when a |
jump |
A jump defining the deviation from normal behavior. |
# Imagine the garbage truck normally comes every Monday, but if # Monday is a state holiday, then it comes on Tuesday instead. In this case # we can use `event = on_state_holiday` as a trigger to define an alternative # event rule. on_normal_trash_day <- on_wday("Monday") on_state_holiday <- on_month("Sep") & on_mweek(1) & on_wday("Monday") on_trash_day <- on_event(on_normal_trash_day, on_state_holiday, days(1)) # A Monday in September event_in("2019-09-09", on_normal_trash_day)#> [1] TRUE#> [1] TRUE#> [1] TRUE#> [1] FALSE#> [1] FALSE#> [1] TRUE