diff --git a/DESCRIPTION b/DESCRIPTION index 4ed7c816..69a7c1bb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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", , "jaseziv83@gmail.com", role = c("aut", "cre", "cph")), person("Tony", "ElHabr", , "anthonyelhabr@gmail.com", role = "ctb"), diff --git a/NEWS.md b/NEWS.md index 2f40536a..cc7dfdea 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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) diff --git a/R/get_match_report.R b/R/get_match_report.R index 8cdb5b89..5cd01495 100644 --- a/R/get_match_report.R +++ b/R/get_match_report.R @@ -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}) diff --git a/R/internals.R b/R/internals.R index 06396665..12d68cf0 100644 --- a/R/internals.R +++ b/R/internals.R @@ -197,7 +197,7 @@ gsub("_Var", "", .) %>% gsub("#", "Num_", .) %>% gsub("%", "_percent", .) %>% - gsub("_Performance", "", .) %>% + # gsub("_Performance", "", .) %>% gsub("_Penalty", "", .) %>% gsub("1/3", "Final_Third", .) %>% gsub("\\+/-", "Plus_Minus", .) %>% diff --git a/R/tm_squad_stats.R b/R/tm_squad_stats.R index 32a4e3ad..41b24847 100644 --- a/R/tm_squad_stats.R +++ b/R/tm_squad_stats.R @@ -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() diff --git a/tests/testthat/test-fbref.R b/tests/testthat/test-fbref.R index a8f82910..f65c8825 100644 --- a/tests/testthat/test-fbref.R +++ b/tests/testthat/test-fbref.R @@ -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))