Skip to contents

get_births is a function that allows the user to get a demographic dataset of the number and rate of births based on the given parameters.

Usage

get_births(v_state = "National", v_year = 2021, year_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. Default is 2021.

year_groups

Logical. Specifies whether to aggregate the output by year groups.

Value

A demographic dataset containing the selected year (group, when year_groups = TRUE), state, state code (CVE_GEO), the number of births and the birth rate in each row,

Examples

get_births(v_state = c("Aguascalientes", "Campeche"),
           v_year = c(1995, 2021, 2046),
           year_groups = TRUE)
#> # A tibble: 6 x 5
#>   year_group  state          CVE_GEO births birth_rate
#>   <fct>       <fct>            <int>  <int>      <dbl>
#> 1 [1995,2021] Aguascalientes       1 676967     0.0219
#> 2 [1995,2021] Campeche             4 464712     0.0212
#> 3 (2021,2046] Aguascalientes       1 553134     0.0135
#> 4 (2021,2046] Campeche             4 439544     0.0147
#> 5 (2046,Inf]  Aguascalientes       1  76754     0.0107
#> 6 (2046,Inf]  Campeche             4  68578     0.0124

get_births(v_state = "National",
           v_year = c(1985, 2005, 2046),
           year_groups= FALSE)
#> # A tibble: 3 x 5
#>    year state    CVE_GEO  births birth_rate
#>   <int> <fct>      <int>   <int>      <dbl>
#> 1  1985 National       0 2392768     0.0318
#> 2  2005 National       0 2280834     0.0217
#> 3  2046 National       0 1735451     0.0118