after: Specify the start and end of a schedule

View source: R/direction.R

afterR Documentation

Specify the start and end of a schedule

Description

Creates a schedule of events occuring before or after either a certain date or another scheduled event.

Usage

after(start_event, within_given = NULL)

before(end_event, within_given = NULL)

in_between(start_event, end_event, within_given = NULL)

on_or_after(start_event, within_given = NULL)

on_or_before(end_event, within_given = NULL)

Arguments

start_event, end_event

The start and/or end events of the schedule. Can be either:

  • A date-time object or

  • A schedule.

within_given

Required only when either start_date or end_date is a schedule. Can be either:

  • A string shortcut for a period type: either "day", "week", "month", "quarter" or "year". Or,

  • A date accessor function. Eg. lubridate::month().

Details

When start_event and/or end_event are schedules they are likely to come around every year. To have any events which can occur 'before' or 'after' them, they need a limit specified by the within_given argument. This can either be date accessor function like lubridate::month() or lubridate::year() or the provided character shortcuts "day", "week", "month", "quarter" or "year".

Value

A schedule object.

Examples

christmas <-  only_occur(in_month("Dec"), on_mday(25))
new_years_eve <-  only_occur(in_month("Dec"), on_mday(31))

after_christmas <- after(christmas, within_given = "year")

schedule_days(after_christmas, from = 2000, to = 2001)

in_between_christmas_and_new_years_eve <-
    in_between(christmas,
               new_years_eve,
               within_given = lubridate::year)

schedule_days(in_between_christmas_and_new_years_eve, from = 2000, to = 2001)


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