setup: Set up ares Environment

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

View source: R/ares.r

Description

Set up ares environmental by cacching the data, formatting dates, creating holidays, and subsetting on data.

Usage

1
2
setup(dataset, date.var, weights = NULL, selection = NULL, 
	date.format = "%d/%m/%Y", weekday.ref = "Sun", holidays = TRUE, ...)

Arguments

dataset

the data frame for the analysis

date.var

string with the name of the column that holds the date variable. It should be a text variable or a factor

weights

an optional vector of weights to be used during the estimation process. See Details

selection

indicator variable for sub-setting. It can be either a quoted string with the name of a column in dataset or a vector

date.format

a string indicating the date format for the horizontal axis. Default is dd/mm/yyyy See strptime for options

weekday.ref

a 3-letter string that match the reference weekday in the U.S. English locale. For example, "Mon" for Monday. Default is "Sun"

holidays

logical indicating if holidays should be created. Default is TRUE. See Details

...

further options for gen_holidays

Details

This function is intended to cache the dataset and set up some environment objects in R so the rest of the library can work properly. Although most of the functions can work stand alone, some of them depend on the object .ares.active.dataset and .ares.selection.

The argument weights is an optional vector for weighting. Usually, it is a vector of ones if none is specified, but when the user has prior information about the weights of each observations, it can be set accordingly. It is particularly useful when the dataset has suffered some sort of imputation technique.

First, .ares.selection is assigned to the global environment, then a date formatted variable is created from date.var and a time index is generated. Factors for days of the week, months, quarters and years are defined. Indicator variables for holidays are created if holidays is set to TRUE. The holidays are created by gen_holidays relying on the date variable. The date variable is defined as doe that stands for "date of event". Country-specific holidays can be be generated on set up time for some countries. One can add these country-specific holidays by adding a file named "XX.hol" to the "/R/library/ares/etc" directory, where "XX" is a 2-letter abbreviation of the country name, for instance "BR.hol" stands for the default option Brazil. The holidays file is self documented. Or you can simply send us an email with the holidays and the dates and we add it for you.

Finally, .ares.active.dataset is assigned to the global environment, every instance of this data frame in the search path is removed and it is reattached.

Attention! The .ares.active.dataset is replaced without warnings. Any changes made to it during a session that was not saved will be lost.

Note! Be warned that some functions were renamed in this version in order to avoid conflict with S3 methods, namely those starting with either plot. or print.. Please, change your scripts accordingly.

Value

This function invisibly returns .ares.active.dataset as a data frame.

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
data(admrio)
names(admrio)
setup(admrio,"date")
setup(admrio,"date",selection="warmseason")

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