Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with 'fb_player_season_stats' function. #33

Closed
JonnyHorsley opened this issue May 18, 2021 · 4 comments
Closed

Issue with 'fb_player_season_stats' function. #33

JonnyHorsley opened this issue May 18, 2021 · 4 comments

Comments

@JonnyHorsley
Copy link

Issues with 'fb_player_season_stats' function for players who are listed under a club (using 'fb_player_urls' function), but it is their first season, or they are yet to make an appearance. Please see attached reproducible example.
Issue_Reproducible_Example.R.zip

JaseZiv added a commit that referenced this issue May 20, 2021
@JaseZiv
Copy link
Owner

JaseZiv commented May 20, 2021

The code has been fixed for the anomalies identified, with some functionality improvements, namely that the function is now vectorised:

# these URLs were provided in the MRE with issues:
old_problem_urls <- c("https://fbref.com/en/players/46dc146a/Claudio-Ofosu", 
                      "https://fbref.com/en/players/3bd54918/Joe-Grey",
                      "https://fbref.com/en/players/042f690f/Brad-Young")

# Code is now vectorised:
old_problem_data <- fb_player_season_stats(player_url = old_problem_urls, stat_type = "playing_time")

image

This functionality now means you won't need to loop as you had provided in the MRE:

#### No longer need to loop ####

#Get Pools players' URLs
pools_2021_player_URLs = fb_player_urls("https://fbref.com/en/squads/2af58c3d/Hartlepool-United-Stats")

# Pass all Hartlepool player URLs
pools_player_seasons <- fb_player_season_stats(player_url = pools_2021_player_URLs, stat_type = "playing_time")

image

@JaseZiv JaseZiv closed this as completed May 20, 2021
@JonnyHorsley
Copy link
Author

Great work, thanks!

@ChrisH1997
Copy link

Unfortunaly, fb_player_season_stats() is still failing for some players if the stat-category can't be found on their fbref page.
Example:
fb_player_season_stats("https://fbref.com/en/players/88ced02c/Cameron-Carter-Vickers", stat_type = "passing")
Error in .f(.x[[1L]], .y[[1L]], ...) : check stat type
fb_player_season_stats("https://fbref.com/en/players/881e5db7/Joel-Castro-Pereira", stat_type = "shooting")
Error in .f(.x[[1L]], .y[[1L]], ...) : check stat type
Can be solved by using map(..., possibly(fb_player_season_stats, NA), ...), which takes longer so it would be really nice if this could be fixed.

@JaseZiv
Copy link
Owner

JaseZiv commented Aug 17, 2021

@ChrisH1997 this should hopefully be fixed with version 0.3.2.2.

Thanks for identifying.

@JaseZiv JaseZiv closed this as completed Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants