business_days: Business Days

business_daysR Documentation

Business Days

Description

Check whether a timestamp of class Date or POSIXt is a business day; compute past or future business days.

Usage

is_businessday(x, holidays = NULL)
is_weekend(x)
previous_businessday(x, holidays = NULL, shift = -1)
prev_bday(x, holidays = NULL, shift = -1)
next_businessday(x, holidays = NULL, shift = 1)
next_bday(x, holidays = NULL, shift = 1)

Arguments

x

a vector of class Date or POSIXct

holidays

A vector of class Date, or a character vector in a format that is understood by as.Date, or anything that can be coerced to class Date by as.Date (e.g. POSIXt).

shift

integer

Details

is_weekend checks whether a given date is a Saturday or Sunday.

previous_businessday takes a Date x and returns the last non-weekend day before. When shift is less than -1, the function evaluates to the shift-th previous day. When shift is 0, the function will return x if it is a business day, else the previous business day. next_businessday works analogously. There are shorter-named versions next_bday and prev_bday.

Value

Logical.

Author(s)

Enrico Schumann

References

B.D. Ripley and K. Hornik. Date-Time Classes. R-News, 1(2):8–12, 2001.

See Also

DateTimeClasses

Examples

is_weekend(Sys.Date())
previous_businessday(Sys.Date())
next_businessday(Sys.Date())


enricoschumann/datetimeutils documentation built on April 2, 2024, 11:10 a.m.