Create a schedule of events occurring only when the specified events do not occur.
dont_occur(x, y = NULL)
x, y | Schedule objects. |
---|
A schedule object.
doesnt_occur()
can accept either one or two schedules as input(s):
When a single schedule is used, the function returns a schedule of all events that do not fall on on the input schedule. The result is the negation of the schedule. For example, the negation of all weekdays would be a schedule of all weekend days.
When two schedules are used, the function returns the first schedule but with the events of the second schedule stripped away. This works to remove the events of the second schedule from the first.
This means that doesnt_occur(a, b)
is the equivalent of
only_occur(a, doesnt_occur(b))
This usage works best when composing with the pipe (%>%
) operator.
library(magrittr) my_dates <- seq.Date(as.Date("1999-01-01"), as.Date("1999-01-10"), by = "1 day") happen(in_month("Jan"), my_dates)#> [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE#> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE#> [1] FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE#> [1] TRUE FALSE TRUE TRUE TRUE TRUE TRUE TRUE FALSE TRUEon_christmas <- only_occur(on_mday(25), in_month("Dec")) on_new_years_day <- on_yday(1) on_public_holidays <- also_occur(on_new_years_day, on_christmas) on_business_days <- dont_occur(on_weekend()) %>% dont_occur(on_public_holidays) happen(on_business_days, my_dates)#> [1] FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE FALSE FALSE