Worldcup R Package Jfjelstul [work] -
The package’s major limitation is its cutoff. The last tournament included is Brazil 2014. Data for 2018 (Russia) and 2022 (Qatar) requires merging from other sources or waiting for an update.
If you use this data for analysis or publication, remember to cite the package author and the source data (FIFA/Jason Fjelstul). Happy analyzing
library(dplyr)
goals <- worldcup::goals top_scorers <- goals %>% group_by(player) %>% summarise(goals = n()) %>% arrange(desc(goals))
library(worldcup)
One of the most common uses for this package is tracking the evolution of the game. Here is a quick example of how you might visualize the average goals per match across history:
# Install from GitHub remotes::install_github("jfjelstul/worldcup") library(worldcup) Use code with caution. Core Datasets worldcup r package jfjelstul
Without this package, calculating "Host Nation Goal Difference" would require manually cross-referencing Wikipedia pages for host years and then parsing score strings. With worldcup , it is a simple join and aggregation.
library(dplyr) library(ggplot2) worldcup::matches %>% group_by(tournament_id) %>% summarize(avg_goals = mean(home_team_score + away_team_score)) %>% ggplot(aes(x = tournament_id, y = avg_goals)) + geom_line() + theme_minimal() + labs(title = "Average Goals per World Cup Match") Use code with caution. 🔍 Use Cases for Researchers The package’s major limitation is its cutoff
