Creates Tables 5.6 & 5.7
create_t5.6_and_t5.7.Rd
Table 5.6 Deaths by age and sex of decedent (urban areas)
Table 5.7 Deaths by age and sex of decedent (rural areas)
Variables needed per record:
- `dodyr`: Year of death.
- `death2r`: Rural-Urban Identifier. Optional.
- `death2c`: Sex of the deceased.
- `death2b`: Age of the deceased. Ideally in a grouped format.
Usage
create_t5.6_and_t5.7(
data,
ru_filter = NULL,
age_var,
date_var = "dodyr",
data_year = NA,
tablename = "Table_5_6",
output_path = NULL
)
Arguments
- data
Death records data frame.
- ru_filter
Type of region to filer by (urban/rural). Optional.
- age_var
Age of deceased column of the dataframe.
- date_var
Event year column of the dataframe. Defaults to "dodyr".
- data_year
The year to report on. Defaults to the last in the data.
- tablename
Name of the table to be saved as a csv file. Optional.
- output_path
The path to export the generated csv table. Optional.
Examples
death_data <- construct_sample_death_data()
death_data <- construct_year(death_data, date_col = "death1a", year_col = "dodyr")
death_data <- construct_age(death_data, dob_col = "death2a", age_col = "death2b", end_date_col = "death1a")
death_data <- construct_age_group(death_data, age_col = "death2b", new_col = "death2b_grp")
table_5_6 <- create_t5.6_and_t5.7(death_data, ru_filter = "urban", age_var = "death2b_grp", data_year = 2022)
#> Error in adorn_totals(pivot_wider(summarise(group_by(filter(data, !!sym(date_var) == data_year), !!sym(age_var), death2c), total = n()), names_from = death2c, values_from = total, values_fill = 0), c("col", "row")): at least one targeted column must be of class numeric. Control target variables with the ... argument. adorn_totals should be called before other adorn_ functions.