if (FALSE) {
library(dplyr)
library(ggplot2)
library(forcats)
# Proportion of females in military branches
military %>%
ggplot(aes(x = branch, fill = gender)) +
geom_bar(position = "fill") +
labs(
x = "Branch", y = "Proportion", fill = "Gender",
title = "Proportion of females in military branches"
)
# Proportion of army officer females across ranks
military %>%
filter(
grade == "officer",
branch == "army"
) %>%
ggplot(aes(x = factor(rank), fill = fct_rev(gender))) +
geom_bar(position = "fill") +
labs(
x = "Rank", y = "Proportion", fill = "Gender",
title = "Proportion of army officer females across ranks"
)
}
Run the code above in your browser using DataLab