gen_holidays: Generate Holidays

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/ares.r

Description

Generate indicator variables for holidays and other special dates

Usage

1
2
gen_holidays(date, holidays = NULL, dates = NULL, 
	selection = TRUE, country = NULL)

Arguments

date

date formatted vector. See as.Date

holidays

vector of strings for the holidays names

dates

vector of strings for the holidays dates formatted as "dd/mm" or "dd/mm/yyyy". See Details

selection

a logical indicating whether .ares.selection should honoured

country

a string indicating the country rules. Default is NULL. See Details

Details

This function scans date looking for matches to each element of dates and if it finds any 1 is assigned to the variable 0 otherwise. The column is named according to holidays. If both holidays and date are omitted and country is set to a valid rule, country-specific holidays are included in the matrix. If both .holidays and .dates vectors are set in the global environment they are used instead of country rules (that are overridden) to flag the fixed holidays. Moving holidays based on Easter are computed by the function moving.holidays.

Automatically created holidays are Christmas, New year, Carnaval, Passion, Easter and Corpus Christi. If both holidays and date are supplied by the function caller then the resulting matrix will contain only those holidays and these automatically created holidays will be omitted. Thus, one can use this function for both automatically create holidays and/or some special days indicators. The vector dates can contain dates formatted as both "dd/mm" and "dd/mm/yyyy". The first format will flag all occurrences of that day and month in date and the second, obviously, will flag the only one occurrence.

Other country rules can be added to this function in the future. If you have a list of holidays for you country, send us a note.

Value

A matrix of indicator variables for the holidays with as many rows as date.

Author(s)

Washington Junger wjunger@ims.uerj.br and Antonio Ponce de Leon ponce@ims.uerj.br

References

Schwartz, J., Spix, C., Touloumi, G. et al. (1996) Methodological issues in studies of air pollution and daily counts of deaths or hospital admissions. J Epidemiol. Community Health 50 (suppl 1), S12–S18.

See Also

attach,search,as.Date

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
data(admrio)
names(admrio)
setup(admrio,"date")
# some mexican holidays plus moving holidays
holidays <- c("constitucion","cincomayo","independencia")
dates <- c("05/02","05/05","16/09")
doe <- .aresEnv$ares.active.dataset$doe
mx.holidays <- gen_holidays(doe)

# special days
strikes <- gen_holidays(doe,holidays=c("transportation","hospitals"),
	dates=c("02/04/2001","21/05/2001"))

wjunger/ares documentation built on Dec. 23, 2021, 5:17 p.m.