holidays: TimeWarp Holiday Database

Description Usage Arguments Details Value Examples

View source: R/holidays.R

Description

Functions for querying and manipulating the TimeWarp holiday database

Usage

1
2
3
4
5
6

Arguments

years

numeric vector of years for which to return holiday dates.

type

character string, name of the holiday.

dates

a Date vector, or a character vector that can be converted to Date by dateParse.

silent

do not display warnings.

Details

The TimeWarp holidays database is implemented as an internal named, or type'd, list of data.frame's.

To create a new type of holiday, use registerHolidays. unregisterHolidays will delete the holiday named by type, and addToHolidays will add new days to an existing type of holiday.

allHolidays returns a character vector of all the known holiday types.

Value

holidays returns a Date vector of holidays that fall within the years argument for the given holiday type.

addToHolidays and registerHolidays invisibly return a copy of the data.frame for the given type.

unregisterHolidays invisibly returns NULL.

allHolidays returns a character vector of all holiday type's known to the database.

isHoliday returns a logical vector with TRUE of all holidays in input.

Examples

1
2
3
4
5
6
7
8
9
# Create a holiday type of New Year days for the 20th century.
registerHolidays('NEWYEAR', as.Date(ISOdate(1900:2000,1,1)))

# Return all New Year days for the 1990's
holidays(1990:2000,'NEWYEAR')

# View counts of registered holidays by year
sapply(as.character(1998:2012), function(y)
       sapply(allHolidays(), function(h) length(holidays(y, h, silent=TRUE))))

TimeWarp documentation built on May 2, 2019, 11:11 a.m.