create_dummy: Create a dummy variable from a date vector

Description Usage Arguments Value Examples

View source: R/create_dummies.R

Description

Create a dummy variable that takes the value 0 or 1 to indicate the abscence or presence of a holiday. The day(s) before or after the holiday dates can also be recoded by using the pre and post arguments. For example, if you also want to recode the two days after your specified holiday dates, set post argument to 2.

Usage

1
create_dummy(dates, holiday_dates, pre = 0, post = 0)

Arguments

dates

date

holiday_dates

date

pre

non-negative int. To recode the x days after the holiday dates.

post

non-negative int. To recode the x days before the holiday dates.

Value

A dummy (binary vector)

Examples

1
2
dates <- seq_days(from = "2021-12-24", to = "2021-12-31")
create_dummy(dates, as.Date("2021-12-25"), post = 1)

Glender/DutchDayDummies documentation built on Feb. 24, 2022, 7:15 a.m.