dont_occur: Invert a schedule

View source: R/dont.R

dont_occurR Documentation

Invert a schedule

Description

Create a schedule of events occurring only when the specified events do not occur.

Usage

dont_occur(x, y = NULL)

Arguments

x, y

Schedule objects.

Details

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.

Value

A schedule object.

Examples

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)
happen(dont_occur(in_month("Jan")), my_dates)
happen(on_wday("Sat"), my_dates)
happen(dont_occur(on_wday("Sat")), my_dates)

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

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