Issue with fb_league_stats() for non-domestic leagues
Closed this issue · 3 comments
Having trouble with fb_league_stats() when it comes to non-domestic leagues. Works well with fb_match_results() but when I use a similar format for fb_league_stats() then it doesn't work.
library(worldfootballR)
packageVersion("worldfootballR")
ucl23 <- fb_league_stats(
country = "",
gender = "M",
season_end_year = 2023,
tier = "1st",
non_dom_league_url = "https://fbref.com/en/comps/8/history/Champions-League-Seasons",
stat_type = "standard",
team_or_player = "player"
)
sessionInfo()
This gives the following error msg:
Error: Request failed after 3 attempts
However, fb_match_results() works just fine:
ucl23_results <- fb_match_results(country = "", gender = "M", season_end_year = 2023, tier = "",
non_dom_league_url = "https://fbref.com/en/comps/8/history/Champions-League-Seasons")
For what I can see the non_dom_league_url
param is not actually used inside the fb_league_stats()
function. Not really sure what generated the request failed error but I'm getting this now
Warning message:
In f(...) :
Did not find the expected number of tables on the page (3). Found 80.
and an empty DF.
This looks like a bug. As @francescozonaro points out, I don't think non_dom_league_url
is used in the function. I can look into a fix this weekend.
I've fixed it using the same approach as fb_match_results() but I've not yet properly tested it. Forgot to create the PR yesterday, feel free to start from that or let me know if you want some changes made.