This package is designed to allow users to extract various world football results and player statistics from the following popular football (soccer) data sites:
You can install the
worldfootballR package from github with:
# install.packages("devtools") devtools::install_github("JaseZiv/worldfootballR")
Package vignettes have been built to help you get started with the package.
This vignette will cover the functions to extract data from understat.com
To get a list of all season team URLs for selected teams, use the
understat_team_meta() function (note, to get team names, it might be advisable to look at Understat.com’s spelling of the team names and pass that through to the function):
This section will cover the functions to aid in the extraction of season league statistics from Understat.
The following leagues are currently supported by Understat (these values can be passed in to the
league arguments of most
To be able to extract match results from Understat, which not only have results and expected goals, but they also provide a probablity of a team winning.
To extract the data, use the
# to get the EPL results: epl_results <- understat_league_match_results(league = "EPL", season_start_year = 2020)
The following sections outlines the functions available to extract data at the per-match level
This section will cover off the functions to get team-level data from Transfermarkt.
To get all shots taken and conceded by a team during a season, use the
# for one team: man_city_shots <- understat_team_season_shots(team_url = "https://understat.com/team/Manchester_City/2020")
To get a more granular breakdown of team shooting data for whole seasons, the
understat_team_stats_breakdown() function can be used. This functions returns a breakdown of team shooting data based on the following groupings:
team_urls <- c("https://understat.com/team/Liverpool/2020", "https://understat.com/team/Manchester_City/2020") team_breakdown <- understat_team_stats_breakdown(urls = team_urls)
This section will cover the functions available to aid in the extraction of player data.
To get shooting locations for all games a player has participated in (for as long as Understat has data for), use the
raheem_sterling_shots <- understat_player_shots(player_url = "https://understat.com/player/618")
To get stats for all players of selected teams, run the
Note: Team URLs cal be extracted using
team_players <- understat_team_players_stats(team_url = c("https://understat.com/team/Liverpool/2020", "https://understat.com/team/Manchester_City/2020"))