library(worldcup) library(dplyr) library(ggplot2) goals %>% filter(period == "regular") %>% mutate(minute_bin = floor(minute / 5) * 5) %>% count(minute_bin) %>% ggplot(aes(x = minute_bin, y = n)) + geom_col(fill = "darkgreen") + labs(title = "Most Goals Come Late β Even Before Injury Time", x = "Minute of match", y = "Total goals (1930β2022)")
penalties_in_play <- goals %>% filter(goal_type == "penalty") %>% count(player, sort = TRUE) shootouts <- matches %>% filter(!is.na(home_penalty) | !is.na(away_penalty))
cards %>% filter(card_type == "red") %>% count(team, sort = TRUE) %>% head(10) Brazil, Argentina, Netherlands β passionate or reckless? Show a bar chart. Add a twist: red cards per match, not total (since some teams play more matches). 5. Example Analysis #3: Penalty Kicks β Who Thrives? Combine goals (type == βpenaltyβ) with shootouts from matches .
