in_month: Specify the month(s) of a schedule

View source: R/month.R

in_monthR Documentation

Specify the month(s) of a schedule

Description

Creates a schedule of events occurring in the months specified.

Usage

in_month(...)

Arguments

...

A character or numeric vector of month elements.

Details

Months can be specified using their names (eg. "January"), abbreviations (eg. "Jan") or integers (eg. 1).

Multiple months can be specified in the same function call. For example: in_month(1, 3) produces a schedule of events occurring in January and March. The same thing is achieved by in_month("Jan", "Mar"). Similarly in_month(1:3) produces a schedule of events occurring in January, February and March.

Value

A schedule object.

Examples

my_dates <- seq.Date(as.Date("2000-01-01"),
                     as.Date("2000-04-01"),
                     by = "1 month")

happen(in_month("January"), my_dates)

happen(in_month("Feb"), my_dates)

happen(in_month(3), my_dates)

happen(in_month("Jan", "Mar"), my_dates)

happen(in_month(1:3), my_dates)

## invalid inputs will produce an immediate error
## Not run: 
in_january <- in_month("Janu")
in_january <- in_month(0)
## End(Not run)

jameslairdsmith/gs documentation built on July 19, 2023, 12:49 a.m.