Cleans epop data, downloaded using the wcde() function, for summations of population by 4, 6 or 8 education groups.

edu_group_sum(d = NULL, n = 4, strip_totals = TRUE, factor_convert = TRUE)

Arguments

d

Data frame downloaded from the

n

Number of education groups (from 4, 6 or 8)

strip_totals

Remove total sums in epop column. Will not strip education totals if year < 2015 and n = 8 as 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.

Value

A tibble with the data selected.

Details

Strips the epop data set to relevant rows for the n education groups.

Examples

#> -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
#> v ggplot2 3.3.5 v purrr 0.3.4 #> v tibble 3.1.3 v dplyr 1.0.7 #> v tidyr 1.1.3 v stringr 1.4.0 #> v readr 1.4.0 v forcats 0.5.1
#> -- Conflicts ------------------------------------------ tidyverse_conflicts() -- #> x dplyr::filter() masks stats::filter() #> x dplyr::lag() masks stats::lag()
past_epop %>% filter(year == 2020) %>% mutate(scenario = 2) %>% edu_group_sum()
#> # A tibble: 42,210 x 8 #> scenario name country_code year age sex education epop #> <dbl> <fct> <dbl> <dbl> <fct> <fct> <fct> <dbl> #> 1 2 Bulgaria 100 2020 0--4 Male Under 15 161. #> 2 2 Bulgaria 100 2020 0--4 Male No Education 0 #> 3 2 Bulgaria 100 2020 0--4 Male Primary 0 #> 4 2 Bulgaria 100 2020 0--4 Male Secondary 0 #> 5 2 Bulgaria 100 2020 0--4 Male Post Secondary 0 #> 6 2 Bulgaria 100 2020 0--4 Female Under 15 152. #> 7 2 Bulgaria 100 2020 0--4 Female No Education 0 #> 8 2 Bulgaria 100 2020 0--4 Female Primary 0 #> 9 2 Bulgaria 100 2020 0--4 Female Secondary 0 #> 10 2 Bulgaria 100 2020 0--4 Female Post Secondary 0 #> # ... with 42,200 more rows