JaseZiv / worldfootballR

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

fb_advanced_match_stats() fails when looking for UEFA World Cup qualifiers #211

Closed Gustavo-CR closed 1 year ago

Gustavo-CR commented 1 year ago

Here is the code:

fb_advanced_match_stats(
  match_url = "https://fbref.com/en/comps/6/history/WCQ----UEFA-M-Seasons", 
  stat_type = "posession", 
  team_or_player = "team"
)

I get the following error:

Error in cbind(League, Match_Date, Matchweek, Home_Team, Home_Formation,  : 
  object 'Home_Goals' not found

Package version: worldfootballR_0.6.1.6000 R version: 4.1.2

JaseZiv commented 1 year ago

So the problem here is twofold...

First, you're not using a correct match_url:

match_url = "https://fbref.com/en/comps/6/history/WCQ----UEFA-M-Seasons" this URL is for the competition as a whole.

This is a valid match_url: "https://fbref.com/en/matches/a2c7d162/Sweden-Spain-September-2-2021-WCQ----UEFA-M"

The second problem is that it appears that most of the stats for UEFA World Cup qualifiers aren't available. Not sure if this has always been the case, or if it's only just happened with FBRef's switch to StatsPerform Opta.

This code block works:

ok <- fb_advanced_match_stats(
  match_url = "https://fbref.com/en/matches/a2c7d162/Sweden-Spain-September-2-2021-WCQ----UEFA-M",
  stat_type = "summary",
  team_or_player = "team"
)

While you're MRE doesn't, as there is no other stats available other than summary.

Gustavo-CR commented 1 year ago

That makes sense, thanks for clarifying it.