in_week: Specify the week(s) of a schedule

View source: R/week.R

in_weekR Documentation

Specify the week(s) of a schedule

Description

Creates a schedule of events occurring in the weeks specified.

Usage

in_week(...)

in_isoweek(...)

in_epiweek(...)

Arguments

...

a numeric vector of weeks.

Details

The type of week is determined by the function used. These week types are built atop their definitions in the lubridate package, which are quoted here:

  • week() returns the number of complete seven day periods that have occurred between the date and January 1st, plus one.

  • isoweek() returns the week as it would appear in the ISO 8601 system, which uses a reoccurring leap week.

  • epiweek() is the US CDC version of epidemiological week. It follows same rules as isoweek() but starts on Sunday. In other parts of the world the convention is to start epidemiological weeks on Monday, which is the same as isoweek.

Value

A schedule object.

Examples

my_dates <- seq.Date(from = as.Date("2000-01-01"),
                     to = as.Date("2000-02-01"),
                     by = "1 week")

happen(in_week(1), my_dates)

happen(in_week(1, 3), my_dates)

happen(in_week(1:3), my_dates)

happen(in_isoweek(1), my_dates)

## invalid inputs will produce an immediate error:
## Not run: 
in_week(0)
in_week(54)
in_week(1.5)
## End(Not run)

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