JaseZiv / worldfootballR

A wrapper for extracting world football (soccer) data from FBref, Transfermark, Understat
https://jaseziv.github.io/worldfootballR/
468 stars 60 forks source link

Away_Team is always Major League Soccer #216

Closed mrmorgan17 closed 1 year ago

mrmorgan17 commented 1 year ago

I was working through the Extracting data from FBref tutorial and noticed that with these examples:

# function to extract match report data
liv_mci_2020 <- fb_match_report(match_url = "https://fbref.com/en/matches/47880eb7/Liverpool-Manchester-City-November-10-2019-Premier-League")
dplyr::glimpse(liv_mci_2020)
Rows: 1
Columns: 18
$ League            <chr> "Premier League"
$ Match_Date        <chr> "2019-11-10"
$ Matchweek         <chr> "Premier League (Matchweek …
$ Home_Team         <chr> "Liverpool"
$ Home_Formation    <chr> "4-3-3"
$ Home_Score        <dbl> 3
$ Home_xG           <dbl> 1.1
$ Home_Goals        <chr> "Fabinho · 6&rsquor; Mohame…
$ Home_Yellow_Cards <chr> "0"
$ Home_Red_Cards    <chr> "0"
$ Away_Team         <chr> "Major League Soccer"
$ Away_Formation    <chr> "4-2-3-1"
$ Away_Score        <dbl> 1
$ Away_xG           <dbl> 1.3
$ Away_Goals        <chr> "Bernardo Silva · 78&rsquor…
$ Away_Yellow_Cards <chr> "2"
$ Away_Red_Cards    <chr> "0"
$ Game_URL          <chr> "https://fbref.com/en/match…
# function to extract match summary data
liv_mci_2020_summary <- fb_match_summary(match_url = "https://fbref.com/en/matches/47880eb7/Liverpool-Manchester-City-November-10-2019-Premier-League")
dplyr::glimpse(liv_mci_2020_summary)
Rows: 10
Columns: 27
$ League            <chr> "Premier League", "Premier …
$ Match_Date        <chr> "2019-11-10", "2019-11-10",…
$ Matchweek         <chr> "Premier League (Matchweek …
$ Home_Team         <chr> "Liverpool", "Liverpool", "…
$ Home_Formation    <chr> "4-3-3", "4-3-3", "4-3-3", …
$ Home_Score        <dbl> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
$ Home_xG           <dbl> 1.1, 1.1, 1.1, 1.1, 1.1, 1.…
$ Home_Goals        <chr> "Fabinho · 6&rsquor; Mohame…
$ Home_Yellow_Cards <chr> "0", "0", "0", "0", "0", "0…
$ Home_Red_Cards    <chr> "0", "0", "0", "0", "0", "0…
$ Away_Team         <chr> "Major League Soccer", "Maj…
$ Away_Formation    <chr> "4-2-3-1", "4-2-3-1", "4-2-…
$ Away_Score        <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
$ Away_xG           <dbl> 1.3, 1.3, 1.3, 1.3, 1.3, 1.…
$ Away_Goals        <chr> "Bernardo Silva · 78&rsquor…
$ Away_Yellow_Cards <chr> "2", "2", "2", "2", "2", "2…
$ Away_Red_Cards    <chr> "0", "0", "0", "0", "0", "0…
$ Game_URL          <chr> "https://fbref.com/en/match…
$ Team              <chr> "Liverpool", "Liverpool", "…
$ Home_Away         <chr> "Home", "Home", "Home", "Ho…
$ Event_Time        <dbl> 6, 13, 51, 61, 65, 71, 78, …
$ Is_Pens           <lgl> FALSE, FALSE, FALSE, FALSE,…
$ Event_Half        <dbl> 1, 1, 2, 2, 2, 2, 2, 2, 2, 2
$ Event_Type        <chr> "Goal", "Goal", "Goal", "Su…
$ Event_Players     <chr> "Fabinho", "Mohamed Salah A…
$ Score_Progression <chr> "1:0", "2:0", "3:0", "3:0",…
$ Penalty_Number    <dbl> NA, NA, NA, NA, NA, NA, NA,…
test_urls_multiple <- c("https://fbref.com/en/matches/c0996cac/Bordeaux-Nantes-August-21-2020-Ligue-1",
                        "https://fbref.com/en/matches/9cbccb37/Dijon-Angers-August-22-2020-Ligue-1")

advanced_match_stats <- fb_advanced_match_stats(match_url = test_urls_multiple, stat_type = "possession", team_or_player = "player")
dplyr::glimpse(advanced_match_stats)
Columns: 40
$ League                <chr> "Ligue 1", "Ligue 1", "…
$ Match_Date            <chr> "2020-08-21", "2020-08-…
$ Matchweek             <chr> "Ligue 1 (Matchweek 1)"…
$ Home_Team             <chr> "Bordeaux", "Bordeaux",…
$ Home_Formation        <chr> "4-3-3", "4-3-3", "4-3-…
$ Home_Score            <dbl> 0, 0, 0, 0, 0, 0, 0, 0,…
$ Home_xG               <dbl> 0.5, 0.5, 0.5, 0.5, 0.5…
$ Home_Goals            <chr> "Mehdi Zerkane · 20&rsq…
$ Home_Yellow_Cards     <chr> "2", "2", "2", "2", "2"…
$ Home_Red_Cards        <chr> "1", "1", "1", "1", "1"…
$ Away_Team             <chr> "Major League Soccer", …
$ Away_Formation        <chr> "4-4-2", "4-4-2", "4-4-…
$ Away_Score            <dbl> 0, 0, 0, 0, 0, 0, 0, 0,…
$ Away_xG               <dbl> 0.2, 0.2, 0.2, 0.2, 0.2…
$ Away_Goals            <chr> "", "", "", "", "", "",…
$ Away_Yellow_Cards     <chr> "3", "3", "3", "3", "3"…
$ Away_Red_Cards        <chr> "0", "0", "0", "0", "0"…
$ Game_URL              <chr> "https://fbref.com/en/m…
$ Team                  <chr> "Bordeaux", "Bordeaux",…
$ Home_Away             <chr> "Home", "Home", "Home",…
$ Player                <chr> "Josh Maja", "Remi Oudi…
$ Player_Num            <dbl> 9, 28, 18, 10, 12, 7, 2…
$ Nation                <chr> "NGA", "FRA", "KOR", "N…
$ Pos                   <chr> "FW", "FW", "LW", "LW",…
$ Age                   <chr> "21-238", "23-277", "27…
$ Min                   <dbl> 45, 45, 74, 16, 63, 27,…
$ Touches_Touches       <dbl> 13, 22, 30, 11, 36, 14,…
$ `Def Pen_Touches`     <dbl> 0, 1, 1, 0, 0, 0, 1, 1,…
$ `Def 3rd_Touches`     <dbl> 0, 8, 5, 2, 3, 3, 11, 1…
$ `Mid 3rd_Touches`     <dbl> 8, 9, 14, 6, 19, 6, 32,…
$ `Att 3rd_Touches`     <dbl> 5, 5, 11, 3, 15, 5, 7, …
$ `Att Pen_Touches`     <dbl> 1, 0, 3, 0, 0, 0, 0, 0,…
$ Live_Touches          <dbl> 13, 22, 30, 11, 36, 14,…
$ Succ_Dribbles         <dbl> 1, 0, 1, 0, 1, 0, 0, 1,…
$ Att_Dribbles          <dbl> 1, 1, 1, 1, 2, 0, 0, 1,…
$ Succ_percent_Dribbles <dbl> 100.0, 0.0, 100.0, 0.0,…
$ Mis_Dribbles          <dbl> 0, 0, 6, 3, 2, 2, 2, 0,…
$ Dis_Dribbles          <dbl> 1, 0, 3, 0, 1, 0, 1, 0,…
$ Rec_Receiving         <dbl> 12, 13, 21, 11, 26, 9, …
$ Prog_Receiving        <dbl> 4, 0, 2, 2, 3, 1, 1, 0,…

The Away_Team column is always "Major League Soccer" which seems to be a bug

JaseZiv commented 1 year ago

Hi @mrmorgan17, thanks for raising. I will work on a fix for this.

Will update comments here once a patch is pushed.

JaseZiv commented 1 year ago

This should now be resolved in version 0.6.1.7000.

Install using.

devtools::install_github("JaseZiv/worldfootballR")

Thanks for raising the issue

mrmorgan17 commented 1 year ago

I updated to version 0.6.1.7000 and still had the same issue with the fb_advanced_match_stats() function:

fb_advanced_match_stats(
  match_url = "https://fbref.com/en/matches/e62685d4/Manchester-United-Leeds-United-August-14-2021-Premier-League",
  stat_type = "keeper"
) %>% 
  select(Team, Player, Min, Game_URL)

Result:

                 Team        Player Min
1   Manchester United  David de Gea  90
2 Major League Soccer Illan Meslier  90
                                                                                            Game_URL
1 https://fbref.com/en/matches/e62685d4/Manchester-United-Leeds-United-August-14-2021-Premier-League
2 https://fbref.com/en/matches/e62685d4/Manchester-United-Leeds-United-August-14-2021-Premier-League