Skip to contents

get_deaths is a function that allows the user to get a demographic dataset containing deaths and death rates, based on the given paramaters.

Usage

get_deaths(
  v_state = "National",
  v_year = 2021,
  v_sex = "Total",
  v_age = c(0, 5, 15, 25, 45, 55, 65, 70),
  age_groups = TRUE
)

Arguments

v_state

Character vector specifying the state(s) that the function will return.

v_year

Numeric vector that specifies the year(s) to return. Must have numbers between 1970 and 2050.

v_sex

Character vector that selects sex. Options: Female, Male and Total.

v_age

Numeric vector that specifies the age(s) to return.

age_groups

Specifies whether to aggregate the output by age groups.

Value

A demographic dataset based on the selected parameters

Examples

get_deaths(v_state =  "Chiapas",
           v_year = 2015,
           v_sex = "Total",
           v_age = c(0, 15, 45, 75),
           age_groups = FALSE)
#> # A tibble: 4 x 7
#>    year state   CVE_GEO   age sex   deaths death_rate
#>   <int> <fct>     <int> <int> <chr>  <int>      <dbl>
#> 1  2015 Chiapas       7     0 Total   2785   0.0220  
#> 2  2015 Chiapas       7    15 Total     69   0.000637
#> 3  2015 Chiapas       7    45 Total    213   0.00394 
#> 4  2015 Chiapas       7    75 Total    487   0.0431  

get_deaths(v_state = c("Aguascalientes", "Campeche"),
           v_year = c(2010, 2021),
           v_sex = "Male",
           v_age = c(0, 15, 45, 75),
           age_groups = TRUE)
#> # A tibble: 16 x 7
#>     year state          CVE_GEO sex   age_group deaths death_rate
#>    <int> <fct>            <int> <chr> <fct>      <int>      <dbl>
#>  1  2010 Aguascalientes       1 Male  [0,15]       273   0.00133 
#>  2  2010 Aguascalientes       1 Male  (15,45]      743   0.00277 
#>  3  2010 Aguascalientes       1 Male  (45,75]     1360   0.0141  
#>  4  2010 Aguascalientes       1 Male  (75,Inf]     816   0.0910  
#>  5  2010 Campeche             4 Male  [0,15]       232   0.00174 
#>  6  2010 Campeche             4 Male  (15,45]      527   0.00270 
#>  7  2010 Campeche             4 Male  (45,75]     1057   0.0142  
#>  8  2010 Campeche             4 Male  (75,Inf]     717   0.0903  
#>  9  2021 Aguascalientes       1 Male  [0,15]       206   0.000976
#> 10  2021 Aguascalientes       1 Male  (15,45]      826   0.00243 
#> 11  2021 Aguascalientes       1 Male  (45,75]     2072   0.0141  
#> 12  2021 Aguascalientes       1 Male  (75,Inf]    1127   0.0870  
#> 13  2021 Campeche             4 Male  [0,15]       193   0.00135 
#> 14  2021 Campeche             4 Male  (15,45]      637   0.00269 
#> 15  2021 Campeche             4 Male  (45,75]     1593   0.0148  
#> 16  2021 Campeche             4 Male  (75,Inf]     993   0.0923