wdi <- read_csv(C:/Users/yudit/Downloads/wdi_parl.csv)
regional_avg <- wdi_2019 %>% group_by(region) %>% # Change ‘SG.GEN.PARL.ZS’ to ‘prop_women_parl’ (or whatever you renamed it to) summarize(avg_women = mean(prop_women_parl, na.rm = TRUE))
ggplot(regional_avg, aes(x = reorder(region, avg_women), y = avg_women, fill = region)) + geom_col() + coord_flip() + guides(fill = “none”) + labs(x = NULL, y = “Avg % Women in Parliament”) + theme_light()
library(tidyverse) library(plotly)
progress_data <- read_csv(“C:/Users/yudit/Downloads/wdi_parl.csv”) %>% # Filter for 2019 (the last year in your dataset) filter(year %in% c(2000, 2019), country %in% c(“Rwanda”, “United Arab Emirates”, “United States”, “Mexico”, “Spain”, “Ethiopia”)) %>% select(country, year, SG.GEN.PARL.ZS) %>% # This creates ‘yr2000’ and ‘yr2019’ columns pivot_wider(names_from = year, names_prefix = “yr”, values_from = SG.GEN.PARL.ZS)
p_progress <- ggplot(progress_data) + geom_segment(aes(x = yr2000, xend = yr2019, y = country, yend = country), color = “grey”) + geom_point(aes(x = yr2000, y = country), color = “red”, size = 3) + geom_point(aes(x = yr2019, y = country), color = “blue”, size = 3) + theme_minimal() + labs(title = “Progress: 2000 (Red) vs 2019 (Blue)”, subtitle = “Change in % Women in Parliament”, x = “% Women in Parliament”, y = NULL)
ggplotly(p_progress)