JaseZiv / worldfootballR

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

Unable to retrieve match_date of games from get_advanced_match_stats #128

Closed lvnxtemirlan closed 2 years ago

Setlem commented 2 years ago

Hi, Same issue here (does not apply to match date only):

JaseZiv commented 2 years ago

Hi all,

Can you please include all code you used to get these errors, and also your environment details (package version, R version, OS, etc). sessionInfo() will output this information.

JaseZiv commented 2 years ago

I have received an email with some examples from another user reporting issues with a few of the FBref functions not returning match dates and the away team.

The following code provides some examples of functions not returning data as expected:

library(worldfootballR)
library(tidyverse)

game_urls <- c("https://fbref.com/en/matches/d59305e1/Paris-Saint-Germain-Metz-May-21-2022-Ligue-1",
               "https://fbref.com/en/matches/e81453d3/Liverpool-Real-Madrid-May-28-2022-Champions-League",
               "https://fbref.com/en/matches/e6a099a7/El-Clasico-Real-Madrid-Barcelona-March-20-2022-La-Liga")

match_report <- get_match_report(match_url = game_urls) 

match_summary <- get_match_summary(match_url = game_urls) 

team_summary <- get_advanced_match_stats(match_url = game_urls, stat_type = "summary",team_or_player = "team") 

player_summary <- get_advanced_match_stats(match_url = game_urls,stat_type = "summary",team_or_player = "player")

I will work on a fix for this

Setlem commented 2 years ago

Hi all,

Can you please include all code you used to get these errors, and also your environment details (package version, R version, OS, etc). sessionInfo() will output this information.

Hi JaseZiv,

Here is my environment details:

R version 4.1.2 (2021-11-01) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale: [1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252 LC_MONETARY=French_France.1252 [4] LC_NUMERIC=C LC_TIME=French_France.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] compiler_4.1.2 tools_4.1.2

These are examples of functions not working properly:

urls <- get_match_urls(country = "FRA", gender = "M", season_end_year = 2022, tier = "1st") detailstatssummary <- get_advanced_match_stats(match_url = urls, stat_type = "summary", team_or_player = "team") write.xlsx(x= detailstatssummary, file = "detailstatssummary.xlsx", row.names = FALSE)

Thanks a lot for your help.

lvnxtemirlan commented 2 years ago

Hi all,

Can you please include all code you used to get these errors, and also your environment details (package version, R version, OS, etc). sessionInfo() will output this information.

Hi JaseZiv,

Issue is solved. Small adjustment in the page. https://github.com/JaseZiv/worldfootballR/blob/main/R/get_match_report.R#L26 The following code was changed:

replace this
tryCatch( {Match_Date <- each_game_page %>% rvest::html_nodes("div:nth-child(1) div strong a") %>% rvest::html_text() %>% .[3]}, error = function(e) {Match_Date <- NA}) 

with this

tryCatch( {Match_Date <- each_game_page %>% rvest::html_nodes("div:nth-child(2) div strong a") %>% rvest::html_text() %>% .[3]}, error = function(e) {Match_Date <- NA})
JaseZiv commented 2 years ago

This has now been resolved as of version 0.5.3.1000.

Thanks for raising it all.