Computes the crude death rate (deaths per 1,000 population) per province and year, joining get_ine_deaths() and get_ine_population() output. The symmetric counterpart to crude_birth_rate() — see rate_of_natural_increase() to combine the two.

crude_death_rate(deaths_df, pop_df)

Arguments

deaths_df

Deaths tibble as returned by get_ine_deaths() $data_provinces (columns nuts3_code, province_name, year, age, total). Unlike crude_birth_rate()'s births_df, this is age-specific, so it is summed over age internally before computing the rate.

pop_df

Population tibble as returned by get_ine_population()$data (columns nuts3_code, year, age, total).

Value

A tibble with nuts3_code, province_name, year, cdr.

Examples

deaths <- tibble::tibble(
  nuts3_code = "ES111", province_name = "A Coruna", year = 2023,
  age = c(0, 1), total = c(1, 49)
)
pop <- tibble::tibble(
  nuts3_code = "ES111", year = 2023, age = c(0, 1), total = c(5000, 5000)
)
crude_death_rate(deaths, pop)
#> # A tibble: 1 × 4
#>   nuts3_code province_name  year   cdr
#>   <chr>      <chr>         <dbl> <dbl>
#> 1 ES111      A Coruna       2023     5