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 CRAN version of worldfootballR
with:
install.packages("worldfootballR")
You can install the released version of worldfootballR
from GitHub with:
# install.packages("devtools")
::install_github("JaseZiv/worldfootballR") devtools
library(worldfootballR)
Package vignettes have been built to help you get started with the package.
This vignette will cover the functions to extract data from transfermarkt.com
To be able to join data player between FBref and Transfermarkt, player_dictionary_mapping()
has been created. There are over 6,100 players who have been listed for teams in the Big 5 Euro leagues on FBref since the start of the 2017-18 seasons, with all of these mapped together. This is expected to be updated and grow over time. The raw data is stored here
<- player_dictionary_mapping()
mapped_players ::glimpse(mapped_players)
dplyr#> Rows: 6,378
#> Columns: 4
#> $ PlayerFBref <chr> "Aaron Connolly", "Aaron Cresswell", "Aarón Escandell", "A…
#> $ UrlFBref <chr> "https://fbref.com/en/players/27c01749/Aaron-Connolly", "h…
#> $ UrlTmarkt <chr> "https://www.transfermarkt.com/aaron-connolly/profil/spiel…
#> $ TmPos <chr> "Centre-Forward", "Left-Back", "Goalkeeper", "Attacking Mi…
The following section will outline the various functions available to find different URLs to be able to pass through the Transfermarkt suite of functions outlined in this vignette.
To get a list of URLs for each team in a particular season from transfermarkt.com, the tm_league_team_urls()
function can be used. If the country/countries aren’t available in the main data set, the function can also accept a League URL from transfermarkt.com. To get the league URL, use the filtering options towards the top of transfermarkt.com, select the country and league you want to collect data from, head to that page, and copy the URL.
<- tm_league_team_urls(country_name = "England", start_year = 2020)
team_urls # if it's not a league in the stored leagues data in worldfootballR_data repo:
<- tm_league_team_urls(start_year = 2020, league_url = "https://www.transfermarkt.com/league-one/startseite/wettbewerb/GB3") league_one_teams
To get a list of player URLs for a particular team in transfermarkt.com, the tm_team_player_urls()
function can be used.
tm_team_player_urls(team_url = "https://www.transfermarkt.com/fc-burnley/startseite/verein/1132/saison_id/2020")
To get a list of staff URLs for a particular team(s) and staff role in transfermarkt.com, the tm_league_staff_urls()
function can be used.
The staff roles that can be passed to the function via the staff_role
argument are below:
# get a list of team URLs for the EPL 2021/22 season
<- tm_league_team_urls(country_name = "England", start_year = 2021)
epl_teams # get all EPL managers for the 2021/22 season
<- tm_team_staff_urls(team_urls = epl_teams, staff_role = "Manager")
epl_managers
# get all EPL goal keeping coaches for the 2021/22 season
<- tm_team_staff_urls(team_urls = epl_teams, staff_role = "Goalkeeping Coach") epl_gk_coaches
This section will cover the functions to aid in the extraction of season team statistics and information for whole leagues.
To be able to extract league tables for select matchday(s), the below function can be used.
The function can accept either the country name, season start year and matchday number(s), or for leagues not contained in the worldfootballR_data repository, it can accept the league URL, season start year and matchday number(s).
#----- to get the EPL table after matchday 1 of the 20/21 season: -----#
<- tm_matchday_table(country_name="England", start_year="2020", matchday=1)
epl_matchday_1_table ::glimpse(epl_matchday_1_table)
dplyr#> Rows: 40
#> Columns: 13
#> $ country <chr> "England", "England", "England", "England", "England", "Engla…
#> $ league <chr> "Premier League", "Premier League", "Premier League", "Premie…
#> $ matchday <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ rk <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18…
#> $ squad <chr> "Arsenal", "Leicester", "Chelsea", "Newcastle", "Wolves", "Ma…
#> $ p <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ w <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1…
#> $ d <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
#> $ l <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0…
#> $ gf <dbl> 3, 3, 3, 2, 2, 2, 4, 1, 1, 1, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 3…
#> $ ga <dbl> 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 4, 1, 1, 1, 3, 2, 2, 2, 3, 3, 0…
#> $ g_diff <dbl> 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, -1, -1, -1, -1, -2, -2, -2, -2,…
#> $ pts <dbl> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3…
# #----- to get the EPL table after each matchdays from matchday 1 to matchday 35 of the 20/21 season: -----#
# epl_matchday_1to35_table <- tm_matchday_table(country_name="England", start_year="2020", matchday=c(1:35))
#----- to get the League One table after each matchdays from matchday 1 to matchday 5 of the 20/21 season: -----#
<- tm_matchday_table(start_year="2020", matchday=1:5,
league_one_matchday_1_table league_url="https://www.transfermarkt.com/league-one/startseite/wettbewerb/GB3")
::glimpse(league_one_matchday_1_table)
dplyr#> Rows: 240
#> Columns: 13
#> $ country <chr> "England", "England", "England", "England", "England", "Engla…
#> $ league <chr> "League One", "League One", "League One", "League One", "Leag…
#> $ matchday <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ rk <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18…
#> $ squad <chr> "Swindon Town", "Lincoln City", "Charlton", "Ipswich", "Accri…
#> $ p <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ w <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
#> $ d <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0…
#> $ l <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1…
#> $ gf <dbl> 3, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0…
#> $ ga <dbl> 1, 0, 0, 0, 0, 0, 1, 0, 2, 2, 1, 1, 1, 1, 0, 0, 2, 1, 3, 2, 2…
#> $ g_diff <dbl> 2, 2, 2, 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -2, -…
#> $ pts <dbl> 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0…
To be able to extract all debutants making either their league or professional debut, the tm_league_debutants()
function can be used.
To see all league debutants (regardless of their professional status), set debut_type = "league"
, while setting debut_type = "pro"
will only return debutants in the selected league who are making their professional debuts.
The variables debut_start_year
and debut_end_year
set time periods on when debutant data is required for. As with all transfermarkt functions, this season value is the starting year if the season, ie for the 2021-22 LaLiga season, this value is set to 2021.
# Laliga players making their LaLiga debut in 2021/2022
<- tm_league_debutants(country_name = "Spain", debut_type = "league", debut_start_year = 2021, debut_end_year = 2021)
laliga_debutants ::glimpse(laliga_debutants)
dplyr#> Rows: 170
#> Columns: 20
#> $ comp_name <chr> "LaLiga", "LaLiga", "LaLiga", "LaLiga", "LaLiga", …
#> $ country <chr> "Spain", "Spain", "Spain", "Spain", "Spain", "Spai…
#> $ comp_url <chr> "https://www.transfermarkt.com/laliga/startseite/w…
#> $ player_name <chr> "Gavi", "Cristhian Mosquera", "Ilias Akhomach", "Á…
#> $ player_url <chr> "https://www.transfermarkt.com/gavi/profil/spieler…
#> $ position <chr> "Central Midfield", "Centre-Back", "Right Winger",…
#> $ nationality <chr> "Spain", "Spain", "Spain", "Spain", "Austria", "Sp…
#> $ second_nationality <chr> NA, "Colombia", "Morocco", "Dominican Republic", N…
#> $ debut_for <chr> "FC Barcelona", "Valencia CF", "FC Barcelona", "FC…
#> $ debut_date <date> 2021-08-29, 2022-01-19, 2021-11-20, 2021-09-20, 2…
#> $ opponent <chr> "Getafe CF", "Sevilla FC", "RCD Espanyol Barcelona…
#> $ goals_for <dbl> 2, 1, 1, 1, 1, 3, 1, 1, 3, 2, 3, 4, 5, 3, 0, 0, 0,…
#> $ goals_against <dbl> 1, 1, 0, 1, 1, 0, 1, 0, 4, 0, 0, 3, 2, 2, 1, 0, 1,…
#> $ age_debut <chr> "17 years 24 days", "17 years 06 months 23 days", …
#> $ value_at_debut <dbl> NA, NA, 1.0e+05, 5.0e+05, 8.0e+06, NA, 4.0e+05, NA…
#> $ player_market_value <dbl> 4.0e+07, NA, 3.0e+06, 5.0e+06, 8.0e+06, NA, 4.0e+0…
#> $ appearances <dbl> 24, 4, 2, 4, 6, 1, 1, 1, 7, 12, 8, 3, 19, 4, 3, 1,…
#> $ goals <dbl> 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0,…
#> $ minutes_played <dbl> 1587, 112, 125, 97, 189, 10, 4, 10, 418, 285, 430,…
#> $ debut_type <chr> "league", "league", "league", "league", "league", …
# English League One players making their PRO debuts in 2021/2022
<- tm_league_debutants(country_name = "", league_url = "https://www.transfermarkt.com/league-one/startseite/wettbewerb/GB3", debut_type = "pro", debut_start_year = 2021, debut_end_year = 2021)
league_one_PRO_debutants ::glimpse(league_one_PRO_debutants)
dplyr#> Rows: 149
#> Columns: 20
#> $ comp_name <chr> "League One", "League One", "League One", "League …
#> $ country <chr> "England", "England", "England", "England", "Engla…
#> $ comp_url <chr> "https://www.transfermarkt.com/league-one/profideb…
#> $ player_name <chr> "Tyreece Campbell", "Chiekh Thiam", "Daniel Kanu",…
#> $ player_url <chr> "https://www.transfermarkt.com/tyreece-campbell/pr…
#> $ position <chr> "midfield", "defence", "attack", "midfield", "midf…
#> $ nationality <chr> "England", "Italy", "England", "England", "England…
#> $ second_nationality <chr> NA, NA, NA, NA, NA, "England", NA, NA, NA, NA, "Ni…
#> $ debut_for <chr> "Charlton Athletic", "Fleetwood Town", "Charlton A…
#> $ debut_date <date> 2022-02-19, 2022-03-08, 2022-02-12, 2022-03-12, 2…
#> $ opponent <chr> "Oxford United", "Sunderland AFC", "Wigan Athletic…
#> $ goals_for <dbl> 0, 1, 1, 1, 0, 4, 0, 1, 0, 2, 1, 2, 1, 1, 0, 1, 0,…
#> $ goals_against <dbl> 4, 3, 2, 0, 2, 1, 2, 1, 2, 1, 2, 1, 4, 1, 2, 2, 2,…
#> $ age_debut <chr> "-", "-", "-", "-", "16 years 07 months 12 days", …
#> $ value_at_debut <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ player_market_value <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ appearances <dbl> 2, 3, 1, 1, 2, 1, 1, 8, 14, 34, 3, 13, 1, 4, 1, 2,…
#> $ goals <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0,…
#> $ minutes_played <dbl> 4, 44, 8, 16, 16, 0, 4, 316, 1177, 2927, 78, 842, …
#> $ debut_type <chr> "pro", "pro", "pro", "pro", "pro", "pro", "pro", "…
To be able to extract a list of all players whose contracts expire in a selected year, the tm_expiring_contracts()
can be used.
Set the contract_end_year
to be equal to the calendar year the contracts are due to expire.
#----- LaLiga players with expiring contracts in 2022: -----#
<- tm_expiring_contracts(country_name = "Spain", contract_end_year = 2023)
laliga_expiring ::glimpse(laliga_expiring)
dplyr#> Rows: 114
#> Columns: 14
#> $ comp_name <chr> "LaLiga", "LaLiga", "LaLiga", "LaLiga", "LaLiga", …
#> $ country <chr> "Spain", "Spain", "Spain", "Spain", "Spain", "Spai…
#> $ comp_url <chr> "https://www.transfermarkt.com/laliga/startseite/w…
#> $ player_name <chr> "Jan Oblak", "Carlos Soler", "Memphis Depay", "Gav…
#> $ player_url <chr> "https://www.transfermarkt.com/jan-oblak/profil/sp…
#> $ position <chr> "Goalkeeper", "Central Midfield", "Centre-Forward"…
#> $ nationality <chr> "Slovenia", "Spain", "Netherlands", "Spain", "Spai…
#> $ second_nationality <chr> NA, NA, "Ghana", NA, "Netherlands", NA, "Guadeloup…
#> $ current_club <chr> "Atlético de Madrid", "Valencia CF", "FC Barcelona…
#> $ contract_expiry <date> 2023-06-30, 2023-06-30, 2023-06-30, 2023-06-30, 2…
#> $ contract_option <chr> "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", …
#> $ player_market_value <dbl> 6.0e+07, 5.0e+07, 4.5e+07, 4.0e+07, 4.0e+07, 4.0e+…
#> $ transfer_fee <dbl> 16000000, NA, 0, NA, 3900000, NA, 72000000, NA, 40…
#> $ agent <chr> "Miha Mlakar", "Promoesport", "TEAM DEPAY", "Puyol…
#----- Can even do it for non-standard leagues - English League One players with expiring contracts in 2022: -----#
# league_one_expiring <- tm_expiring_contracts(country_name = "",
# contract_end_year = 2023,
# league_url = "https://www.transfermarkt.com/league-one/startseite/wettbewerb/GB3")
To get a list of all reported current injuries for a selected league, use the tm_league_injuries()
function:
# to get all current injuries for LaLiga
<- tm_league_injuries(country_name = "Spain")
laliga_injuries ::glimpse(laliga_injuries)
dplyr#> Rows: 33
#> Columns: 14
#> $ comp_name <chr> "LaLiga", "LaLiga", "LaLiga", "LaLiga", "LaLiga", …
#> $ country <chr> "Spain", "Spain", "Spain", "Spain", "Spain", "Spai…
#> $ comp_url <chr> "https://www.transfermarkt.com/laliga/startseite/w…
#> $ player_name <chr> "Thomas Lemar", "Näis Djouahra", "Iñigo Ruiz de Ga…
#> $ player_url <chr> "https://www.transfermarkt.com/thomas-lemar/profil…
#> $ position <chr> "Attacking Midfield", "Left Winger", "Central Midf…
#> $ current_club <chr> "Atlético de Madrid", "Real Sociedad", "RCD Mallor…
#> $ age <dbl> 26, 22, 28, 29, 28, 32, 25, 18, 21, 34, 28, 30, 22…
#> $ nationality <chr> "France", "France", "Spain", "Brazil", "Colombia",…
#> $ second_nationality <chr> "Guadeloupe", "Algeria", NA, NA, "Spain", NA, NA, …
#> $ injury <chr> "Muscle Injury", "Muscle Injury", "Cruciate Ligame…
#> $ injured_since <date> 2022-03-09, 2022-03-08, 2022-02-21, 2022-02-28, 2…
#> $ injured_until <date> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
#> $ player_market_value <dbl> 4.0e+07, 4.0e+05, 2.5e+06, 4.5e+07, 2.0e+05, 6.0e+…
#----- Can even do it for non-standard leagues - get all current injuries for League One in England
# league_one_injuries <- tm_league_injuries(country_name = "",
# league_url = "https://www.transfermarkt.com/league-one/startseite/wettbewerb/GB3")
This section will cover off the functions to get team-level data from Transfermarkt.
To get all the arrivals and departures for a team (or teams) in a season and data regarding the transfer (transfer value, contract length, where they came from/went to, etc), the tm_team_transfers()
function can be used. This function can return either summer
, winter
or all
for both transfer_windows
:
#----- for one team: -----#
<- tm_team_transfers(team_url = "https://www.transfermarkt.com/fc-bayern-munchen/startseite/verein/27/saison_id/2020", transfer_window = "all")
bayern ::glimpse(bayern)
dplyr#> Rows: 25
#> Columns: 21
#> $ team_name <chr> "Bayern Munich", "Bayern Munich", "Bayern Munich", …
#> $ league <chr> "Bundesliga", "Bundesliga", "Bundesliga", "Bundesli…
#> $ country <chr> "Germany", "Germany", "Germany", "Germany", "German…
#> $ season <chr> "2020", "2020", "2020", "2020", "2020", "2020", "20…
#> $ transfer_type <chr> "Arrivals", "Arrivals", "Arrivals", "Arrivals", "Ar…
#> $ player_name <chr> "Leroy Sané", "Marc Roca", "Bouna Sarr", "Douglas C…
#> $ player_url <chr> "https://www.transfermarkt.com/leroy-sane/profil/sp…
#> $ player_position <chr> "Left Winger", "Defensive Midfield", "Right-Back", …
#> $ player_age <chr> "24", "23", "28", "30", "18", "23", "31", "19", "19…
#> $ player_nationality <chr> "Germany", "Spain", "Senegal", "Brazil", "France", …
#> $ club_2 <chr> "Man City", "Espanyol", "Marseille", "Juventus", "P…
#> $ league_2 <chr> "Premier League", "LaLiga2", "Ligue 1", "Serie A", …
#> $ country_2 <chr> "England", "Spain", "France", "Italy", "France", "G…
#> $ transfer_fee <dbl> 6.0e+07, 9.0e+06, 8.0e+06, 2.5e+05, 0.0e+00, 0.0e+0…
#> $ is_loan <lgl> FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRU…
#> $ transfer_notes <chr> NA, NA, NA, NA, NA, NA, NA, "loan transfer", "-", "…
#> $ window <chr> "Summer", "Summer", "Summer", "Summer", "Summer", "…
#> $ in_squad <dbl> 45, 37, 38, 26, 11, 40, 42, 14, 12, 16, 50, 3, NA, …
#> $ appearances <dbl> 44, 11, 15, 20, 6, 4, 32, 2, 5, 7, 37, 0, NA, 0, 1,…
#> $ goals <dbl> 10, 0, 0, 1, 0, 0, 9, 0, 0, 0, 7, 0, NA, 0, 0, 0, N…
#> $ minutes_played <dbl> 2627, 519, 810, 663, 113, 360, 1313, 69, 102, 230, …
#----- or for multiple teams: -----#
# team_urls <- tm_league_team_urls(country_name = "England", start_year = 2020)
# epl_xfers_2020 <- tm_team_transfers(team_url = team_urls, transfer_window = "all")
To get basic statistics (goals, appearances, minutes played, etc) for all games played by players for a squad season, the tm_squad_stats()
function can be used:
#----- for one team: -----#
<- tm_squad_stats(team_url = "https://www.transfermarkt.com/fc-bayern-munchen/startseite/verein/27/saison_id/2020")
bayern ::glimpse(bayern)
dplyr#> Rows: 45
#> Columns: 12
#> $ team_name <chr> "Bayern Munich", "Bayern Munich", "Bayern Munich", "Bay…
#> $ league <chr> "Bundesliga", "Bundesliga", "Bundesliga", "Bundesliga",…
#> $ country <chr> "Germany", "Germany", "Germany", "Germany", "Germany", …
#> $ player_name <chr> "Manuel Neuer", "Alexander Nübel", "Sven Ulreich", "Ron…
#> $ player_url <chr> "https://www.transfermarkt.com/manuel-neuer/profil/spie…
#> $ player_pos <chr> "Goalkeeper", "Goalkeeper", "Goalkeeper", "Goalkeeper",…
#> $ player_age <dbl> 34, 23, 31, 21, 18, 19, 28, 24, 24, 24, 18, 20, 31, 20,…
#> $ nationality <chr> "Germany", "Germany", "Germany", "Germany", "Germany", …
#> $ in_squad <dbl> 47, 40, 3, 12, 4, 39, 46, 46, 40, 44, 11, 16, 47, 4, 38…
#> $ appearances <dbl> 46, 4, 0, 0, 0, 35, 45, 37, 33, 36, 6, 7, 39, 1, 15, 1,…
#> $ goals <dbl> 0, 0, 0, 0, 0, 1, 2, 1, 2, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0…
#> $ minutes_played <dbl> 4200, 360, 0, 0, 0, 2589, 3793, 2691, 2516, 2924, 113, …
#----- or for multiple teams: -----#
# team_urls <- tm_league_team_urls(country_name = "England", start_year = 2020)
# epl_team_players_2020 <- tm_squad_stats(team_url = team_urls)
To get player valuations for all teams in a league season, use the get_player_market_values()
function:
#----- Can do it for a single league: -----#
<- get_player_market_values(country_name = "Australia",
a_league_valuations start_year = 2021)
::glimpse(a_league_valuations)
dplyr#> Rows: 330
#> Columns: 19
#> $ comp_name <chr> "A-League Men", "A-League Men", "A-League Men…
#> $ region <chr> "Asia", "Asia", "Asia", "Asia", "Asia", "Asia…
#> $ country <chr> "Australia", "Australia", "Australia", "Austr…
#> $ season_start_year <int> 2021, 2021, 2021, 2021, 2021, 2021, 2021, 202…
#> $ squad <chr> "Melbourne City FC", "Melbourne City FC", "Me…
#> $ player_num <chr> "1", "33", "42", "4", "22", "5", "36", "34", …
#> $ player_name <chr> "Tom Glover", "Matthew Sutton", "Ahmad Taleb"…
#> $ player_position <chr> "Goalkeeper", "Goalkeeper", "Goalkeeper", "Ce…
#> $ player_dob <date> 1997-12-24, 2000-03-07, 2002-12-04, 1991-01-…
#> $ player_age <dbl> 24, 22, 19, 31, 28, 34, 19, 23, 33, 19, 30, 2…
#> $ player_nationality <chr> "Australia", "Australia", "Australia", "Portu…
#> $ current_club <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
#> $ player_height_mtrs <chr> "1.96", NA, NA, "1.82", "1.87", "1.88", NA, "…
#> $ player_foot <chr> " ", " ", " ", "right", "left", "right", " ",…
#> $ date_joined <chr> "2019-08-06", "2020-09-10", "2020-12-01", "20…
#> $ joined_from <chr> "Tottenham Hotspur U23", "Melbourne Victory",…
#> $ contract_expiry <chr> "2023-06-30", "2022-06-30", "2023-06-30", "20…
#> $ player_market_value_euro <dbl> 800000, 100000, 50000, 500000, 450000, 300000…
#> $ player_url <chr> "https://www.transfermarkt.com/tom-glover/pro…
#----- Can also do it for multiple leagues: -----#
# big_5_valuations <- get_player_market_values(country_name = c("England", "Spain", "France", "Italy", "Germany"),
# start_year = 2021)
#----- Can also do it for non standard leagues: -----#
# league_one_valuations <- get_player_market_values(country_name = "",
# start_year = 2021,
# league_url = "https://www.transfermarkt.com/league-one/startseite/wettbewerb/GB3")
This section will cover the functions available to aid in the extraction of player data.
To get information about a player, like their age, foot, where they were born, who they play for, their contract details, social media accounts and a whole lot more, use the tm_player_bio()
function.:
#----- for a single player: -----#
<- tm_player_bio(player_url = "https://www.transfermarkt.com/eden-hazard/profil/spieler/50202")
hazard_bio ::glimpse(hazard_bio)
dplyr#> Rows: 1
#> Columns: 19
#> $ player_name <chr> "Eden Hazard"
#> $ name_in_home_country <chr> "Eden Michael Hazard"
#> $ date_of_birth <chr> "1991-01-07"
#> $ place_of_birth <chr> "La Louvière"
#> $ age <chr> "31"
#> $ height <dbl> 1.75
#> $ citizenship <chr> "Belgium"
#> $ position <chr> "attack - Left Winger"
#> $ foot <chr> "right"
#> $ player_agent <chr> "Relatives"
#> $ current_club <chr> "Real Madrid"
#> $ joined <chr> "2019-07-01"
#> $ contract_expires <chr> "2024-06-30"
#> $ outfitter <chr> "Nike"
#> $ twitter <chr> "http://twitter.com/hazardeden10"
#> $ facebook <chr> "http://www.facebook.com/edenhazard/"
#> $ instagram <chr> "http://www.instagram.com/hazardeden_10/"
#> $ player_valuation <dbl> 1.8e+07
#> $ URL <chr> "https://www.transfermarkt.com/eden-hazard/profil…
#----- for multiple players: -----#
# # can make use of a tm helper function:
# burnley_player_urls <- tm_team_player_urls(team_url = "https://www.transfermarkt.com/fc-burnley/startseite/verein/1132/saison_id/2020")
# # then pass all those URLs to the tm_player_bio
# burnley_bios <- tm_player_bio(player_urls = burnley_player_urls)
To be able to get an individual player(s) injury history from transfermarkt, use the tm_player_injury_history()
function.
#----- for a single player: -----#
<- tm_player_injury_history(player_urls = "https://www.transfermarkt.com/eden-hazard/profil/spieler/50202")
hazard_injuries ::glimpse(hazard_injuries)
dplyr#> Rows: 29
#> Columns: 9
#> $ player_name <chr> "Eden Hazard", "Eden Hazard", "Eden Hazard", "Eden Haza…
#> $ player_url <chr> "https://www.transfermarkt.com/eden-hazard/profil/spiel…
#> $ season_injured <chr> "21/22", "21/22", "21/22", "20/21", "20/21", "20/21", "…
#> $ injury <chr> "Abdominal Influenza", "Muscular problems", "Hamstring …
#> $ injured_since <date> 2021-11-19, 2021-10-08, 2021-06-28, 2021-05-21, 2021-0…
#> $ injured_until <date> 2021-11-30, 2021-10-22, 2021-08-12, 2021-05-23, 2021-0…
#> $ duration <chr> "11 days", "14 days", "45 days", "2 days", "38 days", "…
#> $ games_missed <chr> "3", "1", NA, "1", "8", "7", "8", "1", "6", "2", "2", "…
#> $ club <chr> "Real Madrid", "Real Madrid", "Real Madrid", "Real Madr…
#----- for multiple players: -----#
# # can make use of a tm helper function:
# burnley_player_urls <- tm_team_player_urls(team_url = "https://www.transfermarkt.com/fc-burnley/startseite/verein/1132/saison_id/2021")
# # then pass all those URLs to the tm_player_bio
# burnley_player_injuries <- tm_player_injury_history(player_urls = burnley_player_urls)
From version 0.4.7, users now have the ability to get historical data for club staff from transfermarkt.
The following two functions can be used, depending on the need (in addition to the helper function tm_team_staff_urls()
detailed above).
You can extract all employees by role in a club’s history using tm_team_staff_history()
.
The list of roles that can be passed to the staff_roles
argument can be found here, and they’re also listed below:
# get a list of team URLs for the EPL 2021/22 season
<- tm_league_team_urls(country_name = "England", start_year = 2021)
epl_teams #----- then use the URLs to pass to the function, and select the role you wish to see results for: -----#
<- tm_team_staff_history(team_urls = epl_teams, staff_role = "Manager")
club_manager_history ::glimpse(club_manager_history)
dplyr#> Rows: 532
#> Columns: 17
#> $ team_name <chr> "Manchester City", "Manchester City", "Man…
#> $ league <chr> "Premier League", "Premier League", "Premi…
#> $ country <chr> "England", "England", "England", "England"…
#> $ staff_role <chr> "Manager", "Manager", "Manager", "Manager"…
#> $ staff_name <chr> "Pep Guardiola", "Manuel Pellegrini", "Rob…
#> $ staff_url <chr> "https://www.transfermarkt.com/pep-guardio…
#> $ staff_dob <chr> "Jan 18, 1971", "Sep 16, 1953", "Nov 27, 1…
#> $ staff_nationality <chr> "Spain", "Chile", "Italy", "Wales", "Swede…
#> $ staff_nationality_secondary <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
#> $ appointed <date> 2016-07-01, 2013-07-01, 2009-12-19, 2008-…
#> $ end_date <date> NA, 2016-06-30, 2013-05-13, 2009-12-19, 2…
#> $ days_in_post <dbl> 2089, 1095, 1241, 563, 332, 794, 1386, 118…
#> $ matches <dbl> 337, 166, 191, 77, 45, 97, 176, 95, 12, 0,…
#> $ wins <dbl> 251, 101, 113, 37, 19, 34, 77, 39, 4, 0, 9…
#> $ draws <dbl> 36, 27, 38, 15, 11, 19, 39, 22, 4, 0, 11, …
#> $ losses <dbl> 50, 38, 40, 25, 15, 44, 60, 34, 4, 0, 20, …
#> $ ppg <dbl> 2.34, 1.99, 1.97, 1.64, 1.51, 1.25, 1.53, …
#----- can also get other roles: -----#
# club_caretaker_manager_history <- tm_team_staff_history(team_urls = epl_teams, staff_role = "Caretaker Manager")
To be able to get all roles held by a selected staff member(s), the tm_staff_job_history()
function can be used.
The function accepts one argument, staff_urls
, which can be extracted using tm_team_staff_urls()
explained in the helpers section above.
# get a list of team URLs for the EPL 2021/22 season
# epl_teams <- tm_league_team_urls(country_name = "England", start_year = 2021)
# get all EPL goal keeping coaches for the 2021/22 season
<- tm_team_staff_urls(team_urls = epl_teams[1:3], staff_role = "Goalkeeping Coach")
epl_gk_coaches
# then you can pass these URLs to the function and get job histories for the selected staff members
<- tm_staff_job_history(staff_urls = epl_gk_coaches)
epl_gk_coach_job_histories ::glimpse(epl_gk_coach_job_histories)
dplyr#> Rows: 17
#> Columns: 23
#> $ name <chr> "Xabier Mancisidor", "Xabier Mancisidor", "Xabier Ma…
#> $ current_club <chr> "Man City", "Man City", "Man City", "Man City", "Man…
#> $ current_role <chr> "Goalkeeping Coach", "Goalkeeping Coach", "Goalkeepi…
#> $ date_of_birth <chr> "May 24, 1970", "May 24, 1970", "May 24, 1970", "May…
#> $ place_of_birth <chr> "Pasaia", "Pasaia", "Pasaia", "Pasaia", "Pasaia", "I…
#> $ citizenship <chr> "Spain", "Spain", "Spain", "Spain", "Spain", "Englan…
#> $ position <chr> "Goalkeeping Coach", "Goalkeeping Coach", "Goalkeepi…
#> $ club <chr> "Man City", "Málaga CF", "Real Madrid", "Real Socied…
#> $ appointed <chr> "2013-06-24", "2011-01-04", "2009-06-02", "1998-10-2…
#> $ contract_expiry <chr> NA, "2013-06-23", "2010-05-27", "2009-06-01", "1998-…
#> $ days_in_charge <dbl> 3192, 901, 359, 3874, 113, 1359, 729, 3916, 729, 111…
#> $ matches <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2, NA, N…
#> $ wins <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0, NA, N…
#> $ draws <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1, NA, N…
#> $ losses <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 1, NA, N…
#> $ players_used <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 18, NA, …
#> $ avg_goals_for <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.…
#> $ avg_goals_against <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.…
#> $ ppm <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.…
#> $ staff_url <chr> "https://www.transfermarkt.com/xabier-mancisidor/pro…
#> $ coaching_licence <chr> NA, NA, NA, NA, NA, NA, NA, "UEFA A Licence", "UEFA …
#> $ agent <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, "Paulo Roberto C…
#> $ avg_term_as_coach <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, "0.02 Years", "0…