Skip to contents

Get the season stats for all teams / players in a selected league

Usage

fb_league_stats(
  country,
  gender,
  season_end_year,
  tier = "1st",
  non_dom_league_url = NA,
  stat_type,
  team_or_player,
  time_pause = 3,
  rate = purrr::rate_backoff(max_times = 3)
)

Arguments

country

the three character country code

gender

gender of competition, either "M" or "F", or both

season_end_year

the year the season(s) concludes

tier

the tier of the league, ie '1st' for the EPL or '2nd' for the Championship and so on

non_dom_league_url

the URL for Cups and Competitions found at https://fbref.com/en/comps/

stat_type

the type of statistic required. Must be one of the following:

  • standard

  • shooting

  • passing

  • passing_types

  • gca

  • defense

  • possession

  • playing_time

  • misc

  • keepers

  • keepers_adv

team_or_player

result either summarised for each team, or individual players

time_pause

the wait time (in seconds) between page loads

rate

passed to `purrr::insistently`. The function can be brittle, and works only on a second or third try. This parameter controls how much the function will retry to get a result.

Value

a dataframe of season stats for all teams / players in a league

Details

[Experimental]

Examples

if (FALSE) {
try({
fb_league_stats(
  country = "ENG",
  gender = "M",
  season_end_year = 2022,
  tier = "1st",
  stat_type = "shooting",
  team_or_player = "player"
)
## Non-domestic league
##   Note that this is more likely to fail due to the volume of players
fb_league_stats(
  country = NA_character_,
  gender = "M",
  season_end_year = 2023,
  tier = NA_character_,
  non_dom_league_url = "https://fbref.com/en/comps/8/history/Champions-League-Seasons",
  stat_type = "standard",
  team_or_player = "player"
)
})
}