Skip to content

Commit

Permalink
Merge pull request #191 from JaseZiv/bug_fixes
Browse files Browse the repository at this point in the history
addressing bugs #174, #184, #187
  • Loading branch information
JaseZiv authored Oct 14, 2022
2 parents 7ffd99b + 035b462 commit 5ccd0ad
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: worldfootballR
Title: Extract and Clean World Football (Soccer) Data
Version: 0.6.0.4000
Version: 0.6.0.5000
Authors@R: c(
person("Jason", "Zivkovic", , "[email protected]", role = c("aut", "cre", "cph")),
person("Tony", "ElHabr", , "[email protected]", role = "ctb"),
Expand Down
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@

* Fotmob functions now pass user agent to headers under the hood (0.6.0.4000)

### Bugs

* `tm_squad_stats()` throwing differing number of rows error [#187](https://github.com/JaseZiv/worldfootballR/issues/187) (0.6.0.5000)
* `.get_match_report_page()` internal function used in a number of `fb_` functions throwing errors for cup tie legs [#174](https://github.com/JaseZiv/worldfootballR/issues/174) (0.6.0.5000)
* `.clean_table_names()` change to internal function that will include '*_performance*' to some column names in `fb_team_match_log_stats()` to address duplicated column names for `stat_type = 'keeper'` [#184](https://github.com/JaseZiv/worldfootballR/issues/184) (0.6.0.5000)


### Breaking Changes

Some column names in output of `fb_team_match_log_stats()` will now include *_Performance* at the end of the name. See [#184](https://github.com/JaseZiv/worldfootballR/issues/184) for more details

***

# worldfootballR 0.6.0

### New functions (and deprecated old ones)
Expand Down
2 changes: 1 addition & 1 deletion R/get_match_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
game <- each_game_page %>% rvest::html_nodes("h1") %>% rvest::html_text()

# tryCatch( {League <- each_game_page %>% rvest::html_nodes("h1+ div a") %>% rvest::html_text()}, error = function(e) {League <- NA})
tryCatch( {League <- each_game_page %>% rvest::html_nodes("h1+ div a") %>% rvest::html_text()}, error = function(e) {League <- NA})
tryCatch( {League <- each_game_page %>% rvest::html_nodes("h1+ div a:nth-child(1)") %>% rvest::html_text()}, error = function(e) {League <- NA})
tryCatch( {Match_Date <- each_game_page %>% rvest::html_nodes(".venuetime") %>% rvest::html_attr("data-venue-date")}, error = function(e) {Match_Date <- NA})
tryCatch( {Matchweek <- each_game_page %>% rvest::html_nodes("h1+ div") %>% rvest::html_text()}, error = function(e) {Matchweek <- NA})

Expand Down
2 changes: 1 addition & 1 deletion R/internals.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
gsub("_Var", "", .) %>%
gsub("#", "Num_", .) %>%
gsub("%", "_percent", .) %>%
gsub("_Performance", "", .) %>%
# gsub("_Performance", "", .) %>%
gsub("_Penalty", "", .) %>%
gsub("1/3", "Final_Third", .) %>%
gsub("\\+/-", "Plus_Minus", .) %>%
Expand Down
6 changes: 3 additions & 3 deletions R/tm_squad_stats.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ tm_squad_stats <- function(team_url) {

if(!is.na(team_data_page)) {

team_name <- team_data_page %>% rvest::html_nodes("h1") %>% rvest::html_text() %>% stringr::str_squish()
league <- team_data_page %>% rvest::html_nodes(".hauptpunkt a") %>% rvest::html_text() %>% stringr::str_squish()
country <- team_data_page %>% rvest::html_nodes(".mediumpunkt img") %>% rvest::html_attr("title")
team_name <- team_data_page %>% rvest::html_nodes(".data-header__headline-wrapper--oswald") %>% rvest::html_text() %>% stringr::str_squish()
league <- team_data_page %>% rvest::html_nodes(".data-header__club a") %>% rvest::html_text() %>% stringr::str_squish()
country <- team_data_page %>% rvest::html_nodes(".vm") %>% rvest::html_attr("title")

team_data_table <- team_data_page %>% rvest::html_nodes("#yw1") %>% rvest::html_node("table") %>% rvest::html_nodes("tbody") %>% rvest::html_children()

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-fbref.R
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ test_that("fb_team_player_stats() works", {
Sys.sleep(3)
test_that("fb_team_match_log_stats() works", {
testthat::skip_on_cran()
liv_passing_log <- fb_team_match_log_stats(team_url= "https://fbref.com/en/squads/822bd0ba/Liverpool-Stats", stat_type= 'passing', time_pause = 4)
expect_type(liv_passing_log, "list")
expect_false(nrow(liv_passing_log) == 0)
liv_keeper_log <- fb_team_match_log_stats(team_url= "https://fbref.com/en/squads/822bd0ba/Liverpool-Stats", stat_type= 'keeper', time_pause = 4)
expect_type(liv_keeper_log, "list")
expect_false(nrow(liv_keeper_log) == 0)

# this should error because the stat type isn't available
expect_error(fb_team_match_log_stats(team_url = "https://fbref.com/en/squads/d6a369a2/Fleetwood-Town-Stats", stat_type= 'keeper_adv', time_pause = 4))
Expand Down

0 comments on commit 5ccd0ad

Please sign in to comment.