rset-add: Deprecated rset helpers

rset-addR Documentation

Deprecated rset helpers

Description

[Deprecated]

  • add_rschedule() is deprecated in favor of using the ... arguments of runion(), rintersect(), and rsetdiff() directly.

  • add_rdates() is deprecated in favor of using runion() in combination with a custom rcustom() rschedule holding the required dates.

  • add_exdates() is deprecated in favor of using rsetdiff() in combination with a custom rcustom() rschedule holding the excluded dates.

Usage

add_rschedule(x, rschedule)

add_rdates(x, rdates)

add_exdates(x, exdates)

Arguments

x

⁠[rset]⁠

An rset to add to.

rschedule

⁠[rschedule]⁠

An rschedule, such as an rrule, runion, rintersect, or rsetdiff.

rdates

⁠[Date]⁠

Dates to forcibly include in the rset.

exdates

⁠[Date]⁠

Dates to forcibly exclude from the rset.

Value

An updated rset.

Examples

on_thanksgiving <- yearly() %>%
  recur_on_day_of_week("Thurs", nth = 4) %>%
  recur_on_month_of_year("Nov")

on_christmas <- yearly() %>%
  recur_on_day_of_month(25) %>%
  recur_on_month_of_year("Dec")

on_labor_day <- monthly() %>%
  recur_on_month_of_year("Sep") %>%
  recur_on_day_of_week("Mon", nth = 1)

# Rather than:
if (FALSE) {
rb <- runion() %>%
  add_rschedule(on_thanksgiving) %>%
  add_rschedule(on_christmas) %>%
  add_rschedule(on_labor_day)
}

# Use the `...` of the `runion()` helper directly:
rb <- runion(on_thanksgiving, on_christmas, on_labor_day)

# Thanksgiving, Christmas, or Labor Day
alma_search("2019-01-01", "2021-01-01", rb)

# Except Labor Day in 2019
# Rather than:
if (FALSE) {
rb2 <- add_exdates(rb, "2019-09-02")
}

# We recommend:
rb2 <- rsetdiff(rb, rcustom("2019-09-02"))

alma_search("2019-01-01", "2021-01-01", rb2)

almanac documentation built on April 14, 2023, 12:23 a.m.