tennis_shots |>
filter(!(round %in% c("Q1", "Q2", "Q3"))) |>
mutate(round_grouped = case_when(
round == "F" ~ "Finals",
round == "SF" ~ "Semi-finals",
round == "QF" ~ "Quarter-finals",
TRUE ~ "Early rounds")) |>
mutate(round_grouped = fct_relevel(round_grouped, "Early rounds", "Quarter-finals", "Semi-finals", "Finals")) |>
ggplot(aes(x = shot_type, fill = outcome_type)) +
geom_bar(position = "fill") + # could remove position = "fill" to get raw counts
labs(x = "Shot type", y = "Proportion", fill = "Outcome Type") +
facet_wrap(~ round_grouped, ncol = 4) +
theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1))