dbConvert | R Documentation |
Converts a population database to another geography using a conversion table and, possibly, raking.
dbConvert( db, conv_table, years = NULL, rake = TRUE, change_rake_args = FALSE, full_BC = TRUE )
db |
Data variable containing the source database to be converted. Expects data to be in data.frame with columns: Year, Type, TypeID, Age, Male, Female, Total. |
conv_table |
Name of conversion table to be read in to provide the proportional relationship ("split") between source and destination geographies. Conversion table path is hardcoded to ensure consistency across population systems, and will find conversion table in ".../ConversionTables/" folder (on the LAN). |
years |
Vector of one or more years to be included in the converted destination data. Default = NULL. If NULL, the function will convert for all years in the source data. If not NULL, the function will convert only the year(s) specified, but return all years in source data (which can be confusing; therefore, it is recommended to include in db only the year(s) to be converted.) |
rake |
Whether raking is required (default) or not. Default = TRUE.
While the |
change_rake_args |
Logical value whether raking argument defaults need to be changed. Default = FALSE. If set to TRUE, user will be asked to set the following arguments:
Regardless of 'change_rake_args' value, |
full_BC |
Logical value whether the region covers all of BC. Default = TRUE. Those regions (e.g., VI, CMAs) that do not cover all of BC should have full_BC = FALSE, and their sum is not checked against the BC total. As well, during conversion, source geographies not included in the destination geographies are dropped from the From and To working datafiles. |
Conversion tables should be in the ".../ConversionTables/" LAN folder so that they can be found, and are expected to be .xlsx files with three unnamed columns with the proportional relationship (aka, "split"), source and destination geographies.
The conversion process is as follows:
Evaluate the conversion table between Geography A (source)and B (destination) for regions that require no conversion (i.e., regions are converted 1-to-1 from Geography A to B). Remove these regions from the conversion process.
Sequentially share out the data relating to the region in Geography A using the conversion factor to the respective region(s) in Geography B.
Aggregate Geography B components that received contributions from multiple regions in Geography A.
If not all regions are 1-to-1, "split" destination geographies must conform to source
totals (aka, "control population totals"), achieved using raking (dbRake
).
If Step (1) removed some 1-to-1 regions, the control totals will be adjusted downward. Destination
control totals (aka, "control region totals", or dbRake's "CtrlRegionTotals") are set as NULL and
will be generated during the raking process from the converted destination data (aka, "InputData").
Any 1-to-1 regions removed during Step (1) are added back to Geography B (under the Geography B naming convention).
Database converted from source to destination geography. If not all allocations were 100, (i.e., some splits < 100), then raking was also done (unless explicitly set to FALSE). Note that Age can be a positive age (e.g., 0, 1, 2, ...), a 5-year age group (e.g., 0-4) or TOTAL.
Overall package documentation: dbutils
()
Other conversion helpers:
conversionRead()
,
conversionTables()
,
geogConvert()
## Not run: dbConvert(db = "POPHAP20", conv_table = "Table-LHA-HSDA-2019.xlsx", rake = FALSE) ## all 100% ## Not run: dbConvert(db = "POPHAP20", conv_table = "Table-LHA-SD-2019") ## some split ## Not run: dbConvert(db = "POPCSE21", conv_table = "Table-CSD-VI_NO_CRD-2020", full_BC = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.