Flag statutory holidays in Ontario
stat_holidays_ON.RdThis function merges a given table containing dates of interest with a holiday table to flag which dates are holidays/observed holidays.
Arguments
- data
(
data.frameordata.table)
Table containingdate_columnthat can be converted toYYYY-MM-DDformat- date_column
(
character)
Name of column indatacorresponding to relevant dates; will be merged with holiday table.- include_observed_holidays
(
logical)
IfTRUE, observed holidays will be included in output.
Value
This function returns the provided input table data with the following
additional columns:
date:date_columninYYY-MM-DDformatholiday: flag indicating whether date corresponds to a holiday or notholiday_weekday: the day of the week when the holiday occurredholiday_name: the name of the holiday occurring on the given date
When include_observed_holidays == TRUE, 3 additional columns will be
returned where observed_holiday = TRUE for any dates on which a holiday
was observed (whether or not that corresponds to the actual date of the
holiday). Additionally, the corresponding weekday and holiday name of
observed holidays will be returned as separate columns.
Examples
if (FALSE) { # \dontrun{
drv <- dbDriver("PostgreSQL")
dbcon <- DBI::dbConnect(drv,
dbname = "db",
host = "domain_name.ca",
port = 1234,
user = getPass("Enter user:"),
password = getPass("password")
)
# derive which encounters were discharged on a holiday
ipadm <- dbGetQuery(db, "SELECT discharge_date_time FROM admdad;")
holidays <- stat_holidays_ON(ipadm, "discharge_date_time")
} # }