I've tried looking at old threads unsuccessfully. I'm trying to plot the share of male legislators in different parliamentary sessions in a histogram.
This is my code, which works but shows the amount of legislators (NOT the share). How can I plot the share? Thanks!
mergedf %>%
ggplot( aes(x = session, fill = factor(sex))) +
geom_histogram (binwidth = 0.5)+
theme_minimal()+
theme(legend.position ="bottom")+
labs(title = "Share of male legislators by session", x= "Session", y = "Share of legislators",
fill ="sex")
Edit: I get the share of legislators with this table, but I don't know how to integrate it in the histogram.
mergedf %>%
tabyl (session, sex) %>%
adorn_percentages() %>%
adorn_pct_formatting ()