Skip to content

Commit

Permalink
2021 update
Browse files Browse the repository at this point in the history
  • Loading branch information
rhirotacouncil committed Nov 9, 2023
1 parent d627b4e commit 5597621
Show file tree
Hide file tree
Showing 3 changed files with 522 additions and 97 deletions.
10 changes: 5 additions & 5 deletions code/02_agency_demo_improv.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ percent_plot <- cp %>% filter(agency_name =='DSNY',gender2!="Other") %>%
ggplot(aes(x = data_year, y = pct.chg_middle)) +
facet_wrap(~gender2, nrow=1) +
geom_hline(yintercept=0, size = 0.5, color="grey") +
geom_point(aes(color=data_year), show.legend = FALSE) + geom_label_repel(data = ~ subset(., data_year %in% c(2019,2020)), aes(label = round(pct.chg_middle, digits=2))) + # pct.chg_middle rounded to 3 decimal places
geom_point(aes(color=data_year), show.legend = FALSE) + geom_label_repel(data = ~ subset(., data_year %in% c(2019,2020,2021)), aes(label = round(pct.chg_middle, digits=2))) + # pct.chg_middle rounded to 3 decimal places
scale_color_discrete() + theme_nycc(facet=TRUE) +
ggtitle("Percent Change") + xlab("Year") + ylab("Percent") + easy_plot_title_size(14)
Expand All @@ -255,7 +255,7 @@ relative_plot <- cp %>% filter(agency_name =='DSNY',gender2!="Other") %>%
scale_color_discrete(name = "Year") + theme_nycc(facet=TRUE) +
ggtitle("Relative Difference") + xlab("Year") + ylab("Number") + easy_plot_title_size(14)
final <- grid.arrange(percent_plot, relative_plot, ncol=2, top = textGrob("DSNY: Gender Diversity (2018-2020)",gp=gpar(fontsize=19, fontfamily="Georgia", font=2)))
final <- grid.arrange(percent_plot, relative_plot, ncol=2, top = textGrob("DSNY: Gender Diversity (2018-2021)",gp=gpar(fontsize=19, fontfamily="Georgia", font=2)))
ggsave(plot = final, "../visuals/DSNY_diversity_by-gender.png")
```
Expand All @@ -275,19 +275,19 @@ percent_plot <- cp %>% filter(agency_name =='DOP') %>%
ggplot(aes(x = data_year, y = pct.chg_middle)) +
facet_wrap(~race_ethnicity, nrow=1) +
geom_hline(yintercept=0, size = 0.25, color="grey") +
geom_point(aes(color=data_year), show.legend = FALSE) + geom_label_repel(data = ~ subset(., data_year %in% c(2019,2020)), aes(label = round(pct.chg_middle, digits=2))) + # pct.chg_middle rounded to 3 decimal places
geom_point(aes(color=data_year), show.legend = FALSE) + geom_label_repel(data = ~ subset(., data_year %in% c(2019,2020,2021)), aes(label = round(pct.chg_middle, digits=2))) + # pct.chg_middle rounded to 3 decimal places
scale_color_discrete() + theme_nycc(facet=TRUE) +
ggtitle("DOP Race") + xlab("Year") + ylab("Percent") + easy_plot_title_size(14)
relative_plot <- cp %>% filter(agency_name =='DOP') %>%
ggplot(aes(x = data_year, y = diff_middle)) +
facet_wrap(~race_ethnicity, nrow=1) +
geom_hline(yintercept=0, size = 0.25, color="grey") +
geom_point(aes(color=data_year), show.legend = FALSE) + geom_label_repel(data = ~ subset(., data_year %in% c(2019,2020)),aes(label = round(diff_middle, 0))) + # diff_middle rounded to 0 to make more sense
geom_point(aes(color=data_year), show.legend = FALSE) + geom_label_repel(data = ~ subset(., data_year %in% c(2019,2020,2021)),aes(label = round(diff_middle, 0))) + # diff_middle rounded to 0 to make more sense
scale_color_discrete() + theme_nycc(facet=TRUE) +
ggtitle("DOP Race") + xlab("Year") + ylab("Relative Difference") + easy_plot_title_size(14)
final2 <- grid.arrange(percent_plot, relative_plot, nrow=2, top = textGrob("DOP: Racial Diversity (2018-2020)", gp=gpar(fontsize=19, fontfamily="Georgia", font=2)))
final2 <- grid.arrange(percent_plot, relative_plot, nrow=2, top = textGrob("DOP: Racial Diversity (2018-2021)", gp=gpar(fontsize=19, fontfamily="Georgia", font=2)))
ggsave(plot = final2, "../visuals/DOP_diversity_by-race.png")
```
Expand Down
Loading

0 comments on commit 5597621

Please sign in to comment.