multiRake | R Documentation |
The raking function, dbRake
, will run for one year of data but the data often needs
to be raked for more than one year. In multiRake, arguments include Years in
the data, any censusYears that should not be raked as these are generally considered
definitive, name of InputData, name of CtrlPopTotals, either name of
CtrlRegionTotals or default of NULL, name of region variable in all data, and whether
you want to change any arguments required by dbRake
.
This is a helper function used to run dbRake
for multiple years.
multiRake( years, censusYears = FALSE, InputData, CtrlPopTotals, CtrlRegionTotals = NULL, VarRegion, change_rake_args = FALSE )
years |
Vector of all years in the data (e.g., Years = 2011:2020). |
censusYears |
Any year(s) that are a census year and should not be raked (e.g., 2011, 2016). Default is FALSE. If all years need to be raked, set as FALSE. |
InputData |
Name of .xlsx or .csv file that contains input data to be raked. This file is assumed to have Region (e.g., "TypeID", "CHSA") by Sex (e.g., 1, 2, 3) as rows, and Ages (e.g., 0, 1, 2, ..., TOTAL) as columns. Values are population counts. |
CtrlPopTotals |
Name of .xlsx or .csv file that contains overall control totals (e.g., "BC AS TOTALS.xlsx"). This file is assumed to have Sex (e.g., 1, 2, 3) as rows and Ages (e.g., 0, 1, 2, ..., TOTAL) as columns. Values are population counts. This file typically has dimensions of 3 (obs) by 103 variables. |
CtrlRegionTotals |
Name of .xlsx or .csv file that contains overall control totals (e.g., "CHSA TOTALS.xlsx"). Default = NULL. This file is assumed to have Region (e.g., 218 CHSAs) as the first column and TOTAL (population counts) as the second column; this file is not broken out by Sex or Age. This file typically has dimensions of n (obs) by 2 variables, where "n" is the number of individual regions (e.g., 218 for CHSA). If no name is provided (i.e., NULL), then region control totals are not used. Instead, the InputData will be used to generate "control" totals. |
VarRegion |
Name of Region variable in all files (e.g., "TypeID", "CHSA"). |
change_rake_args |
Logical value whether any remaining raking argument defaults need to be
changed. Default = FALSE. If set to TRUE, user will be asked to set the following arguments:
CtrlAgeGrpsTotals (default = NULL);
VarSex (otherwise pre-specified as "Sex");
VarSexTotal (otherwise pre-specified from data's column names);
AgeGrpMax (default = NULL which would trigger |
RakedData.csv will be saved to "outputs" folder (which will be created if one does not already exist). If set to TRUE, various interim files will be saved in an "interim_files" folder within "outputs". If set to TRUE, a log file ("raking_log.csv") will also be saved to the "outputs" folder.
Julie Hawkins, BC Stats
The overall raking function: dbRake
()
Other raking helpers:
add.random.fraction.to.cols()
,
adjustSex()
,
allowNegsnoMargin()
,
calc.cols()
,
noNegsneedMargin()
,
noNegsnoMargin()
,
prep.prorate.col()
,
prorate.col()
,
prorate.row()
,
prorate()
,
read.inputs()
,
real.to.int()
,
rename.age.grps()
,
rounded()
## Not run: ## if files need to be read in, set 'change_rake_args' to TRUE multiRake(years = 2011:2020, censusYears = c(2011, 2016), InputData = "POPHAE19.xlsx", CtrlPopTotals = "BC AS TOTALS.xlsx", CtrlRegionTotals = "LHA TOTALS.xlsx", VarRegion = "LHA", change_rake_args = TRUE) ## End(Not run) ## two census years not to be raked ## Not run: multiRake(years = 2012:2016, censusYears = FALSE, InputData = "POPHAE19.xlsx", CtrlPopTotals = "BC AS TOTALS.xlsx", CtrlRegionTotals = "LHA TOTALS.xlsx", VarRegion = "LHA", change_rake_args = FALSE) ## End(Not run) ## all years need to be raked
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.