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)

Arguments

x

[event]

An event defining normal behavior.

event

[event]

An event defining when a jump should occur.

jump

[Period(1) / integer(1)]

A jump defining the deviation from normal behavior.

Examples

# 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
event_in("2019-09-09", on_trash_day)
#> [1] TRUE
# Labor Day Monday should not be trash day event_in("2019-09-02", on_normal_trash_day)
#> [1] TRUE
event_in("2019-09-02", on_trash_day)
#> [1] FALSE
# The day after Labor Day Monday is trash day event_in("2019-09-03", on_normal_trash_day)
#> [1] FALSE
event_in("2019-09-03", on_trash_day)
#> [1] TRUE