JaseZiv / worldfootballR

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

FBRef - Player ID - Duplicate IDs #331

Closed kidshiva closed 1 year ago

kidshiva commented 1 year ago

Hello,

Running the fb_league_stats and I am getting duplicate player IDs for players with the same name - please see screenshot below

image

championship <- fb_league_stats( country = "ENG", gender = "M", season_end_year = 2024, tier = "2nd", non_dom_league_url = NA, stat_type = "playing_time", team_or_player = "player", time_pause = 4 )

library(worldfootballR) packageVersion("worldfootballR") [1] ‘0.6.4.7’

tonyelhabr commented 1 year ago

Can confirm that this is a bug. It's an edge case. I'll have to think about the best way to handle it.

tonyelhabr commented 1 year ago

Resolved by #332.

library(dplyr)
library(worldfootballR)
packageVersion('worldfootballR')
#> [1] '0.6.4.8'
championship <- fb_league_stats(
  country = "ENG",
  gender = "M",
  season_end_year = 2024,
  tier = "2nd",
  non_dom_league_url = NA,
  stat_type = "playing_time",
  team_or_player = "player",
  time_pause = 4
)
#> Please be aware that `fb_league_stats(..., team_or_player = "player")` depends on promises, which may not always work.
#> This message is displayed once per session.

championship |> 
  filter(Player == 'Danny Ward') |> 
  select(Rk, Player, Player_Href)
#> # A tibble: 2 × 3
#>      Rk Player     Player_Href                    
#>   <int> <chr>      <chr>                          
#> 1   623 Danny Ward /en/players/d3ce0e89/Danny-Ward
#> 2   624 Danny Ward /en/players/cfb29823/Danny-Ward