-
Notifications
You must be signed in to change notification settings - Fork 62
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
Improve reliability of fb_league_stats(..., team_or_player = "player")
#396
Conversation
…_stats(..., team_or_player = "player")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all-in-all, i think fb_league_stats(..., team_or_player = "player")
should be ~100% reliable now!
@@ -1,7 +1,7 @@ | |||
Type: Package | |||
Package: worldfootballR | |||
Title: Extract and Clean World Football (Soccer) Data | |||
Version: 0.6.5.0008 | |||
Version: 0.6.6.0000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since fb_league_stats(..., team_or_player = "player")
seems to be a popular function that was buggy before, I think this deserves a little more than a dev version increment!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely, good choice.
@@ -36,7 +36,7 @@ Imports: | |||
readr, | |||
rlang, | |||
rstudioapi, | |||
rvest (>= 1.0.0), | |||
rvest (>= 1.0.4), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notable requirement
|
||
*** | ||
|
||
# worldfootballR 0.6.6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"reset" the NEWS
session <- worldfootballr_chromote_session(url) | ||
player_table <- worldfootballr_html_player_table(session) | ||
session$session$close(wait_ = FALSE) | ||
page <- rvest::read_html_live(url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow, so easy now! (i can completely delete chromote-fbref.R
😄)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have been using rvest::read_html_live()
for work quite a bit, just didn't get to addressing it here though - awesome stuff!
page <- rvest::read_html_live(url) | ||
## for keepers: although URLs have plural term, div elements have singular term | ||
stat_type <- gsub("keepers", "keeper", stat_type) | ||
player_table_element <- page$html_elements(paste0("#div_stats_", stat_type)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before, i hardcoded a search for the #stats_shooting_sh
element. in hindsight, i think this meant that fb_league_stats(..., team_or_player = "player")
only worked for stat_type = "shooting"
?! maybe my thought that our prior code was unreliable was actually more so due to a bug than bad code!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hahaha a very nice unintended fix!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome PR.
Thanks so much for addressing @tonyelhabr.
Fixes #395.
fb_league_stats(..., team_or_player = "player")
to uservest::read_html_live()
fb_league_stats(..., team_or_player = "player")
(😅 )Testing and verifying that all
stat_type
s withfb_league_stats(..., team_or_player = "player")
work.