Cleans epop data, downloaded using the wcde() function, for summations of population by 4, 6 or 8 education groups.
Usage
edu_group_sum(
d = NULL,
n = 4,
strip_totals = TRUE,
factor_convert = TRUE,
year_edu_start = 2020
)Arguments
- d
Data frame downloaded from the
- n
Number of education groups (from 4, 6 or 8)
- strip_totals
Remove total sums in
epopcolumn. Will not strip education totals ifyear < year_edu_startandn = 8as past data on population size by 8 education groups is unavailable.- factor_convert
Convert columns that are character strings to factors, with levels based on order of appearance.
- year_edu_start
Year in which education splits are available for given groupings - in some versions past data is not available for some education groupings. Set to 2020 by default.
Examples
library(tidyverse)
#> ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
#> ✔ dplyr 1.1.4 ✔ readr 2.1.5
#> ✔ forcats 1.0.0 ✔ stringr 1.5.1
#> ✔ ggplot2 4.0.0 ✔ tibble 3.3.0
#> ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
#> ✔ purrr 1.1.0
#> ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
#> ✖ dplyr::filter() masks stats::filter()
#> ✖ dplyr::lag() masks stats::lag()
#> ℹ Use the conflicted package to force all conflicts to become errors
past_epop %>%
filter(year == 2020) %>%
edu_group_sum()
#> # A tibble: 30,000 × 7
#> name country_code year age sex education epop
#> <fct> <dbl> <dbl> <fct> <fct> <fct> <dbl>
#> 1 Bulgaria 100 2020 0--4 Male Under 15 163.
#> 2 Bulgaria 100 2020 0--4 Female Under 15 154.
#> 3 Bulgaria 100 2020 5--9 Male Under 15 171.
#> 4 Bulgaria 100 2020 5--9 Female Under 15 161.
#> 5 Bulgaria 100 2020 10--14 Male Under 15 173.
#> 6 Bulgaria 100 2020 10--14 Female Under 15 163
#> 7 Bulgaria 100 2020 15--19 Male No Education 1.2
#> 8 Bulgaria 100 2020 15--19 Male Primary 13.3
#> 9 Bulgaria 100 2020 15--19 Male Secondary 149.
#> 10 Bulgaria 100 2020 15--19 Male Post Secondary 0
#> # ℹ 29,990 more rows
