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)")
Goals spike just before halftime (45’) and just before full time (80–90’) — fatigue and desperation drive action. 4. Example Analysis #2: Which Nations Lose Their Cool? Count red cards per country using cards . jfjelstul worldcup r package
penalties_in_play <- goals %>% filter(goal_type == "penalty") %>% count(player, sort = TRUE) shootouts <- matches %>% filter(!is.na(home_penalty) | !is.na(away_penalty)) library(worldcup) library(dplyr) library(ggplot2) goals %>