Computes the sex ratio (males per 100 females) per province and year
from age-disaggregated population data. Requires the female/male
columns get_ine_population() provides; get_ine_demog()'s
population_total indicator has no sex breakdown and cannot be used
here.
sex_ratio(pop_df, by_age = FALSE)A tibble with nuts3_code, province_name, year (and age if
by_age = TRUE), sex_ratio.
pop <- tibble::tibble(
nuts3_code = "ES111", province_name = "A Coruna", year = 2023,
age = c(0, 1), female = c(100, 95), male = c(105, 100)
)
sex_ratio(pop)
#> # A tibble: 1 × 4
#> nuts3_code province_name year sex_ratio
#> <chr> <chr> <dbl> <dbl>
#> 1 ES111 A Coruna 2023 105.
sex_ratio(pop, by_age = TRUE)
#> # A tibble: 2 × 5
#> nuts3_code province_name year age sex_ratio
#> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 ES111 A Coruna 2023 0 105
#> 2 ES111 A Coruna 2023 1 105.