Skip to contents

get_population is a function that allows the user to get a demographic dataset regarding population and population proportions based on the given parameters.

Usage

get_population(
  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

State(s) of desired data.

v_year

Year(s) of desired data. Must have numbers between 1970 and 2050.

v_sex

Vector selecting sex. Options: Female, Male and Total.

v_age

Specifies the age bins to aggregate and return.

age_groups

Specifies whether to aggregate the output by age groups.

Value

A demographic dataset indicating the year, the state, the state code (CVE_GEO), the age (group, when age_groups = TRUE), the population and the proportion of each row, in relation to the selected year and sex.

Examples

get_population(v_state =  "Chiapas",
               v_year = 2015,
               v_sex = "Total",
               v_age = c(0, 15, 45, 75),
               age_groups = FALSE)
#> # A tibble: 4 x 8
#>    year state     age CVE_GEO sex   population death_rate proportion
#>   <int> <fct>   <int>   <int> <chr>      <int>      <dbl>      <dbl>
#> 1  2015 Chiapas     0       7 Total     126786   0.0220       0.422 
#> 2  2015 Chiapas    15       7 Total     108299   0.000637     0.360 
#> 3  2015 Chiapas    45       7 Total      54114   0.00394      0.180 
#> 4  2015 Chiapas    75       7 Total      11296   0.0431       0.0376

get_population(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 8
#>     year state          CVE_GEO sex   age_group population death_rate proportion
#>    <int> <fct>            <int> <chr> <fct>          <int>      <dbl>      <dbl>
#>  1  2010 Aguascalientes       1 Male  [0,15]        205735   0.00133      0.355 
#>  2  2010 Aguascalientes       1 Male  (15,45]       268296   0.00277      0.463 
#>  3  2010 Aguascalientes       1 Male  (45,75]        96275   0.0141       0.166 
#>  4  2010 Aguascalientes       1 Male  (75,Inf]        8968   0.0910       0.0155
#>  5  2010 Campeche             4 Male  [0,15]        133246   0.00174      0.324 
#>  6  2010 Campeche             4 Male  (15,45]       194892   0.00270      0.474 
#>  7  2010 Campeche             4 Male  (45,75]        74696   0.0142       0.182 
#>  8  2010 Campeche             4 Male  (75,Inf]        7940   0.0903       0.0193
#>  9  2021 Aguascalientes       1 Male  [0,15]        211029   0.000976     0.297 
#> 10  2021 Aguascalientes       1 Male  (15,45]       340069   0.00243      0.478 
#> 11  2021 Aguascalientes       1 Male  (45,75]       147236   0.0141       0.207 
#> 12  2021 Aguascalientes       1 Male  (75,Inf]       12957   0.0870       0.0182
#> 13  2021 Campeche             4 Male  [0,15]        143179   0.00135      0.287 
#> 14  2021 Campeche             4 Male  (15,45]       237191   0.00269      0.476 
#> 15  2021 Campeche             4 Male  (45,75]       107559   0.0148       0.216 
#> 16  2021 Campeche             4 Male  (75,Inf]       10764   0.0923       0.0216