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

fotmob_get_match_players does not return expected info #226

Closed NikolasSotiriou closed 1 year ago

NikolasSotiriou commented 1 year ago

Hi! Awesome package first of all! A problem I have found is that the function fotmob_get_match_players does not return the info I would expect it to return for an upcoming match for which the lineups have not been announced yet. Specifically, the info I would expect is the predicted lineups which are available on the app.

library(worldfootballR)
packageVersion("worldfootballR")

# code which gets you a data frame containing the match IDs for the World Cup to use below
fotmob_matches <- as.data.frame(fotmob_get_league_matches(league_id = 77))
# the code below is for an upcoming match for which lineups have been announced
match_info1 <- as.data.frame(fotmob_get_match_players(fotmob_matches$id[23]))
# the code below is for an upcoming match for which predicted lineups are available
match_info2 <- as.data.frame(fotmob_get_match_players(fotmob_matches$id[24]))

sessionInfo()
tonyelhabr commented 1 year ago

hmm ok i'll have to take a look at this

NikolasSotiriou commented 1 year ago

Thanks for the quick turnaround. However, I think you fixed an issue different than the one I brought to light. Specifically, when I use this function for a match yet to happen but with a predicted lineup available on Fotmob, I do not that info. In fact, when I use this function for a match yet to happen, I do not even get the info that I used to get before I raised the issue (e.g. time, stadium). Anyway, thanks again.

tonyelhabr commented 1 year ago

When I ran this code with the PR that was merged, the Japan and Croatia match was not played yet. I thought you were looking for the upcoming lineups?

packageVersion("worldfootballR")
#> [1] '0.6.2.1000

options(tibble.print_min = 22)
fotmob_get_match_players(3370555) |> 
  dplyr::select(
    team_name,
    shirt,
    first_name,
    last_name,
    role
  )
# A tibble: 22 × 5
   team_name shirt first_name last_name role      
   <chr>     <chr> <chr>      <chr>     <chr>     
 1 Japan     12    Shuichi    Gonda     Keeper    
 2 Japan     16    Takehiro   Tomiyasu  Defender  
 3 Japan     3     Shogo      Taniguchi Defender  
 4 Japan     22    Maya       Yoshida   Defender  
 5 Japan     14    Junya      Ito       Attacker  
 6 Japan     13    Hidemasa   Morita    Midfielder
 7 Japan     17    Ao         Tanaka    Midfielder
 8 Japan     5     Yuto       Nagatomo  Defender  
 9 Japan     8     Ritsu      Doan      Attacker  
10 Japan     15    Daichi     Kamada    Midfielder
11 Japan     25    Daizen     Maeda     Attacker  
12 Croatia   4     Ivan       Perisic   Midfielder
13 Croatia   14    Marko      Livaja    Attacker  
14 Croatia   9     Andrej     Kramaric  Attacker  
15 Croatia   8     Mateo      Kovacic   Midfielder
16 Croatia   11    Marcelo    Brozovic  Midfielder
17 Croatia   10    Luka       Modric    Midfielder
18 Croatia   19    Borna      Sosa      Defender  
19 Croatia   20    Josko      Gvardiol  Defender  
20 Croatia   6     Dejan      Lovren    Defender  
21 Croatia   22    Josip      Juranovic Defender  
22 Croatia   1     Dominik    Livakovic Keeper 
NikolasSotiriou commented 1 year ago

Example: fotmob_matches <- as.data.frame(fotmob_get_league_matches(league_id = 77)) match_info <- as.data.frame(fotmob_get_match_players(fotmob_matches$id[58]))

With this code I get what I expect now that the lineups have been released for this match. The issue I was raising is that I cannot get the predicted lineup (or any other info, in fact) for upcoming games for which the lineup has not been released yet but for which a predicted lineup is available on the app.

Example:

match_info <- as.data.frame(fotmob_get_match_players(fotmob_matches$id[59])) match_info [1] match_id

<0 rows> (or 0-length row.names)
NikolasSotiriou commented 1 year ago

Also:

packageVersion("worldfootballR") [1] ‘0.6.2’

JaseZiv commented 1 year ago

Also:

packageVersion("worldfootballR")

[1] ‘0.6.2’

Install the latest dev version using devtools::install_github("JaseZiv/worldfootballR"). The latest dev version as Tony said is 0.6.2.1000.

Let us know if the problem still persists after updating.

Thanks

NikolasSotiriou commented 1 year ago

Worked. Thank you!