JaseZiv / worldfootballR

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

using the fb_league_stats #383

Open nadavamit1 opened 2 weeks ago

nadavamit1 commented 2 weeks ago
  1. havent been able to call upon "passing" stats using the "fb_league_stats" function : 2024_team_passing <- fb_league_stats( country = ("ENG,"NED"), gender = "M", season_end_year = 2024, tier = "1st", non_dom_league_url = NA, stat_type = "passing", team_or_player = "player" ) dplyr::glimpse(2024_team_passing)

  2. i've noticed im unable to call upon shooting (for example) data for South American leagues and top 5 leagues at the same time, i'll raise an issue about that as well. the response is: engbra_2023_player_shooting <- fb_league_stats(

    • country = c("ARG","ENG"),
    • gender = "M",
    • season_end_year = c("2023","2024"),
    • tier = "1st",
    • non_dom_league_url = NA,
    • stat_type = "shooting",
    • team_or_player = "player"
    • )
tonyelhabr commented 2 weeks ago

for issue (2), i'm not surprised. i have found that the function becomes inconsistent once it's asked to scrape multiple leagues or seasons. i've had to resort to just calling the function one at a time (for each league/season pair) instead of providing a set of values in country and/or season_end_year, so you might try that for the time being.

i think i may look into using the read_html_live() functionally that was formally added to {rvest} earlier this year. fb_league_stats() currently uses logic from rvest that was in a draft of the read_html_live() function--the issues with fb_league_stats() may simply be resolved by importing read_html_live().

for issue (1), does it work if you try calling the function for just one country? e.g.

team_passing <- fb_league_stats(
  country = "ENG",
  gender = "M",
  season_end_year = 2024,
  tier = "1st",
  non_dom_league_url = NA,
  stat_type = "passing",
  team_or_player = "player"
)

also, this may sound silly, but you might try using a variable name that doesn't begin with a number. i believe that's an invalid thing to do with R.

2024_team_passing <- 'a'
> Error: unexpected input in "2024_"