also_occur: Join schedules together

View source: R/join.R

also_occurR Documentation

Join schedules together

Description

Functions to combine schedules using set operations.

Usage

also_occur(x, y)

only_occur(x, y)

Arguments

x, y

Schedule objects.

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).

Value

A schedule object.

Examples

library(magrittr, warn.conflicts = FALSE)
on_christmas <- only_occur(on_mday(25), in_month("Dec"))

schedule_days(on_christmas, from = 2000, to = 2004)

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)

jameslairdsmith/scheduler documentation built on July 27, 2023, 6:06 p.m.