Functions to combine schedules using set operations.

also_occur(x, y)

only_occur(x, y)

Arguments

x, y

Schedule objects.

Value

A schedule object.

Details

  • also_occur() returns a schedule of events which includes all those present in the first schedule (x) and all those present in the second schedule (y). The resulting output is the union of the two schedules.

  • only_occur() returns a schedule of events which includes only those present in both the first schedule (x) and in the second schedule (y). The resulting output is the intersection of the two schedules.

Each function call is limited to two schedules. But more complex schedules can be made by building schedules on top of one another. This process is greatly eased by using the pipe operator (%>%) from the magrittr package (see Examples).

Examples

library(magrittr, warn.conflicts = FALSE) on_christmas <- only_occur(on_mday(25), in_month("Dec")) schedule_days(on_christmas, from = 2000, to = 2004)
#> [1] "2000-12-25" "2001-12-25" "2002-12-25" "2003-12-25" "2004-12-25"
on_new_years_day <- on_yday(1) on_boxing_day <- on_mday(26) %>% only_occur(in_month("Dec")) on_public_holiday <- on_new_years_day %>% also_occur(on_christmas) %>% also_occur(on_boxing_day) schedule_days(on_public_holiday, from = 2000, to = 2004)
#> [1] "2000-01-01" "2000-12-25" "2000-12-26" "2001-01-01" "2001-12-25" #> [6] "2001-12-26" "2002-01-01" "2002-12-25" "2002-12-26" "2003-01-01" #> [11] "2003-12-25" "2003-12-26" "2004-01-01" "2004-12-25" "2004-12-26"