Jfjelstul Worldcup R Package Official

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)) jfjelstul worldcup r package

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 . Count red cards per country using cards

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 . Add a twist: red cards per match, not