Created
December 27, 2020 23:52
-
-
Save adisarid/cd1cf054bd16cba537a26644554022f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(patchwork) | |
library(glue) | |
tib <- | |
tribble(~sector, ~poor_overall, ~population_portion, ~poor_percent, | |
"secular", 0.27, 0.66, 0.086, | |
"ultra-orthodox", 0.26, 0.11, 0.52, | |
"arab", 0.454, 0.2, 0.47, | |
"others", 0.016, 0.03, 0.113) %>% | |
mutate(sector = factor(sector, levels = c("secular", "arab", | |
"ultra-orthodox", "others"))) %>% | |
pivot_longer(cols = -sector) | |
overall_distribution <- tib %>% | |
filter(name != "poor_percent") %>% | |
mutate(name = recode_factor(name, | |
"population_portion" = "כללית", | |
"poor_overall" = "עניים")) %>% | |
ggplot(aes(x = value, | |
fill = sector, | |
y = name)) + | |
geom_col(color = "black") + | |
ylab("אוכלוסיה") + | |
ggtitle("התפלגות מידת הדתיות", | |
"השוואה בין התפלגות דתיות ודת מקרב כלל האוכלוסיה לעומת עניים") + | |
theme(legend.position = "top") + | |
theme_light() + | |
scale_fill_brewer(palette = "BuPu") + | |
scale_x_continuous(labels = scales::percent_format(1)) + | |
xlab("\u202bשיעור באוכלוסיה [%]") + | |
theme(plot.title = element_text(hjust = 1), | |
plot.subtitle = element_text(hjust = 1)) + | |
guides(fill = guide_legend("מגזר")) | |
poor_percent_plot <- tib %>% | |
filter(name == "poor_percent") %>% | |
ggplot(aes(x = sector, y = value)) + | |
geom_col(fill = "#3398ff") + | |
geom_label(aes(label = glue("{round(value*100)}%"))) + | |
theme_light() + | |
ggtitle("שיעור העוני בכל קבוצה", | |
subtitle = "אחוז העניים מקרב כל מגזר") + | |
scale_y_continuous(labels = scales::percent_format(1)) + | |
ylab("\u202bשיעור העוני [%]") + | |
xlab("מגזר") + | |
theme(plot.title = element_text(hjust = 1), | |
plot.subtitle = element_text(hjust = 1)) | |
overall_distribution / poor_percent_plot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment