JaseZiv / worldfootballR

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

fotmob_get_match_details scrapes and unnests shots data #166

Closed rowzreport closed 2 years ago

rowzreport commented 2 years ago

I am using the latest version: 0.5.12.1000. See below example and comments

#below function gives shot level data. 
#If I remember correctly (not 100% on this), it used to give main match info, and the last column was a shots dataframe. 
#it seems like the below function now just downloads the shots dataframe and unnests it
df1 = fotmob_get_match_details(3915296) ##sample matchid #1
df2 = fotmob_get_match_details(3932406) ##sample matchid #2

Output:

> head(df1[15:19])
# A tibble: 6 × 5
          id event_type   team_id player_id player_name  
       <dbl> <chr>          <int>     <int> <chr>        
1 2447448415 Miss            8655    820581 Ben Brereton 
2 2447450905 Goal            9798    789508 Tom McIntyre 
3 2447456503 AttemptSaved    9798   1123529 Tyrese Fornah
4 2447456983 AttemptSaved    9798    877567 Thomas Holmes
5 2447457197 Miss            9798    212441 Andy Yiadom  
6 2447457543 AttemptSaved    9798     23293 Shane Long   
tonyelhabr commented 2 years ago

Yes, this was a change in 0.5.8. See the NEWS.md

tonyelhabr commented 2 years ago

Yes, this was a change in 0.5.8. See the NEWS.md

The reasoning: most people were using this function for the shot data anyways, so unnesting for users is convenient.

rowzreport commented 2 years ago

Yes I definitely agree that unnesting is super convenient and saves a lot of time.

However, fotmob_get_match_details currently scrapes only the shot data. I.e., with the current set of functions, (I believe) there is not a way to get basic match information including match score, stadium_name, referee_name etc. This used to exist with the old version of the function.

Having a simple function to get the basics, if it's not too much time consuming, would be super helpful,

tonyelhabr commented 2 years ago

But fotmob_get_match_details() didn't return match score, venue, referee, etc. before the unnesting change in 0.5.8. (All the same columns + the unnested shot columns are returned with the existing fotmob_get_match_details() .) Are you asking for a new function? It wouldn't be hard I suppose.

rowzreport commented 2 years ago

Ok fair - I was not 100% sure that match score, venue etc. was returned from fotmob_get_match_details()

In that regard, yes it would be great to have a new function then!

tonyelhabr commented 2 years ago

Ok fair - I was not 100% sure that match score, venue etc. was returned from fotmob_get_match_details()

In that regard, yes it would be great to have a new function then!

I can work on it. I'll leave this issue open until it's done.

tonyelhabr commented 2 years ago

Addressed with #173

rowzreport commented 2 years ago

Thank you!