-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonthly figure_aug22.R
53 lines (40 loc) · 1.85 KB
/
monthly figure_aug22.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
##### Revisión de dato mensual SCLData - Agosto
#### preliminares ######
# add functions to do graphs
source("Indicadores funciones.R")
#remove scientific notation
options(scipen = 999)
#define colors
colors_sex <- c('#176A7B', '#C8DA92')
#### Leer datos SCLData ####
#query dictionary of indicators
dictionary <- idbsocialdataR:::query_dictionary() %>% select(collection, indicator, label_es, label_en)
# query indicator from package
tasa_patrones <- idbsocialdataR::query_indicator(indicator = 'tasa_patrones',
categories = 'sex,ethnicity,age')
##### Gráficas ####
table_evo <- tasa_patrones %>%
# change woman - women/man- men
mutate(sex = case_when(sex == "woman" ~ "women",
sex == "man" ~ "men",
TRUE ~ sex)) %>%
# change ethnicity names for graph
mutate(ethnicity= case_when(ethnicity == "Afro" ~ "Afro-Descendant",
ethnicity == "Indi" ~ "Indigenous Population",
ethnicity == "Otro" ~ "Non-AD/IP",
TRUE ~ ethnicity)) %>%
# filte rpopulation 25_64
filter(age == "25_64")
plot_aux <- table_evo %>%
# keep only countries with Afro-descendant population in their surveys
filter(isoalpha3 %in% c('BRA', 'COL', 'ECU', 'URY')) %>%
# filter only non-AD/IP and AD population
filter(sex != "Total" & ethnicity != "Total" & ethnicity!="Indigenous Population")
# use function from Indicadores funciones
plot_evo <- gg_evo_eth(plot_aux, plot_aux$year, plot_aux$value, plot_aux$ethnicity) +
facet_grid(sex~isoalpha3, scales = "free_y", switch = "y") +
labs(title = "Employers in the main activity (in%), by race",
size = 4)
print(plot_evo)
# Save plot
ggsave(plot = plot_evo, file = "Output/Employers-race.jpg", height = 10, width = 12, units = "cm")