holidays: Holidays

Description Usage Arguments Details Value Note

View source: R/holidays.R

Description

Functions that know about Federal and FRB (Federal Reserve Board) holidays.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
nextBusinessDay(x, holidays = NULL, goodFriday = F, board = F, inaug = board)
previousBusinessDay(x, holidays = NULL, goodFriday = F, board = F, inaug = board)
isHoliday(x, goodFriday = F, board = F, inaug = board, businessOnly = T)
isBusinessDay(x, ...)
isGoodFriday(x)
isEaster(x)
holidays(years, goodFriday = F, board = F, inaug = board, businessOnly = T)
federalHolidays(years, board = F, businessOnly = T)
goodFriday(years)
easter(years)
inaugurationDay(years)
holidaysBetween(startTi, endTi, goodFriday = F, board = F, inaug = board,
                businessOnly = T)

Arguments

x

a ti time index, or something that can be turned into one, such as a yyyymmdd number or a Date object.

holidays

a vector of holidays (in yyyymmdd form) to skip over, or NULL. In the latter case, the holidays function is used to determine days to skip over.

goodFriday

if TRUE, consider Good Friday as a holiday. Default is FALSE because Good Friday is not a federal holiday.

board

if TRUE, the Friday preceding a Saturday NewYears, Independence, Veterans or Christmas Day is considered a holiday.

inaug

if TRUE, consider the U.S. Presidential Inauguration Day to be a holiday, but only if it falls on a weekday.

businessOnly

if TRUE (the default), ignore Saturday NewYears, Independence, Veterans amd Christmas Day holidays. Has no effect if board is TRUE, since that moves Saturday holidays to Friday.

...

arguments passed on to isHoliday

years

numeric vector of 4 digit years

startTi

a daily ti time index, or something that can be turned into one

endTi

a daily ti time index, or something that can be turned into one

Details

Federal law defines 10 holidays. Four of them, NewYears, Independence, Veterans and Christmas, fall on the same date every year. The other six fall on particular days of the week and months (MLK, Presidents, Memorial, Labor, Columbus, and Thanksgiving).

If one of the four fixed-date holidays falls on a Sunday, the federal holiday is celebrated the next day (Monday). If it falls on a Saturday, the preceding day (Friday) is a holiday for the Federal Reserve Board, but not for the Reserve Banks and the banking system as a whole.

Presidential Inauguration day is a Federal holiday only in the DC area, and then only if it falls on a weekday, so it is not included in the holidays returned by federalHolidays, but it can be included in several of the other functions by setting the inaug argument to TRUE.

The function isBusinessDay returns TRUE for x if and only if x is not a holiday, a Saturday or a Sunday.

Value

nextBusinessDay and previousBusinessDay return "business" frequency ti objects.

isHoliday, isGoodFriday, isEaster and isBusinessDay return Boolean vectors as long as x.

easter and goodFriday return numeric vectors of yyyymmdd dates of the appropiate holidays for each year in the years argument.

inaugurationDay returns a numeric vector of yyyymmdd dates of U.S. Presidential Inauguration Days, if any, that fall in the years given in the years argument.

federalHolidays returns a numeric vector of yyyymmdd dates for the federal holidays for each year in years. The names attribute of the returned vector contains the holiday names.

holidays returns a vector like federalHolidays does. The only difference between the two functions is that holidays has the option of including Good Fridays.

holidaysBetween returns a vector of yyyymmdd dates for holidays that fall within the time spanned by [startTi, endTi].

Note

The algorithm for finding Easter dates was found somewhere on the web (I don't remember where) and is unbelievably complex. It would probably be simpler to just celebrate the home opener of the Cleveland Indians instead.


tis documentation built on Sept. 29, 2021, 1:06 a.m.