holiday_data: Holiday Data

View source: R/Holiday_Data.R

holiday_dataR Documentation

Holiday Data

Description

Build Holiday Dataframe of holiday dates between 2 dates in the form of 'yyyy-mm-dd'. Pass a dataframe with the column of dates.

Usage

holiday_data(df, out_df = c("weeks", "days"))

Holiday_Names(name, holiday_dates)

USValentinesDay(year = timeDate::getRmetricsOptions("currentYear"))

USSuperBowl(year = timeDate::getRmetricsOptions("currentYear"))

USSaintPatricksDay(year = timeDate::getRmetricsOptions("currentYear"))

USMothersDay(year = timeDate::getRmetricsOptions("currentYear"))

USFathersDay(year = timeDate::getRmetricsOptions("currentYear"))

USHalloweenDay(year = timeDate::getRmetricsOptions("currentYear"))

USCyberMonday(year)

USJuneteenthDay(year = timeDate::getRmetricsOptions("currentYear"))

Arguments

df

dataframe A dataframe with 1 date column with at least 2 dates.

out_df

character "weeks" is the default, but can also use "days"

name

character Name of the holiday represented by the holiday_dates vector.

holiday_dates

Dates A vector of dates representing the holiday.

year

numeric A vector of year integers.

Value

The result of the function can be either a dataframe with days between the minimum and maximum of the dates provided, or, the default option which is to return a dataframe with weeks instead of days.

The paramater out_df gives the user 2 choices for output. The default output a weeks dataframe with beginning week, ending week, a holiday flag, and a column for the holiday name. The second option returns a dataframe with all the days and day names with the 4 columns mention above.

Note

  • https://github.com/cran/timeDate/blob/master/R/holiday-Dates.R

  • https://www.federalpay.org/holidays

Examples

## Not run: 
weeks_df <- tibble::tibble(weeks = seq.Date(as.Date('2015-01-01'),
as.Date('2020-01-01'), by = 'week'))
holidays_weeks(df = weeks_df) %>% head(10)

## Individual Holidays
years <- seq(2015,2020, by = 1)
US_ValentinesDay <- USValentinesDay(years) %>% as.Date()
Name_Valentines <- Holiday_Names("ValentinesDay",US_ValentinesDay)

## End(Not run)

Fredo-XVII/RToolShed documentation built on March 17, 2024, 12:15 p.m.