From dcf70470c6f30f1742c231576f213f4120167fc4 Mon Sep 17 00:00:00 2001 From: Tony ElHabr Date: Sat, 4 Nov 2023 12:59:14 -0500 Subject: [PATCH 1/2] use gsub instead of iconv --- DESCRIPTION | 2 +- NEWS.md | 4 ++-- R/get_match_results.R | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 058b0732..91a75d2a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: worldfootballR Title: Extract and Clean World Football (Soccer) Data -Version: 0.6.4.0010 +Version: 0.6.4.0011 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 4553cbb0..18271688 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,9 +6,9 @@ * `fb_advanced_match_stats()` throwing errors when there were no stat tables available for matches (0.6.4.0002) [#315](https://github.com/JaseZiv/worldfootballR/issues/315) * `fb_player_match_logs()` failing for players who have played on multiple teams/leagues in the same season (0.6.4.0006) [#327](https://github.com/JaseZiv/worldfootballR/issues/327) * `fb_league_stats(team_or_player = "player")` returning duplicate player hrefs (0.6.4.0008) [#331](https://github.com/JaseZiv/worldfootballR/issues/331) -worldfootballR/issues/327) * `fb_league_stats(team_or_player = "player")` returning wrong season's data for Australian league (0.6.4.0009) [#333](https://github.com/JaseZiv/worldfootballR/issues/333) -* `tm_player_market_values()` returing the player name and valuation on separate rows in the `player_name` column [#338] (https://github.com/JaseZiv/worldfootballR/issues/338) and also returning `NA`s for the `player_age` column [#336](https://github.com/JaseZiv/worldfootballR/issues/336) (0.6.4.0010) +* `tm_player_market_values()` returing the player name and valuation on separate rows in the `player_name` column [#338] (https://github.com/JaseZiv/worldfootballR/issues/338) and also returning `NA`s for the `player_age` column (0.6.4.0010) [#336](https://github.com/JaseZiv/worldfootballR/issues/336) +* `fb_match_results()` returns `NA` goals due to inconsistent `iconv()` behvaior on different systems (0.6.4.0011) [#326](https://github.com/JaseZiv/worldfootballR/issues/326) ### Improvements diff --git a/R/get_match_results.R b/R/get_match_results.R index d5c2a35e..524b4f94 100644 --- a/R/get_match_results.R +++ b/R/get_match_results.R @@ -83,7 +83,7 @@ suppressWarnings( season_summary <- season_summary %>% dplyr::filter(is.na(.data[["Time"]]) | .data[["Time"]] != "Time") %>% - dplyr::mutate(Score = iconv(.data[["Score"]], 'utf-8', 'ascii', sub=' ') %>% stringr::str_squish()) %>% + dplyr::mutate(Score = gsub("–", " ", .data[["Score"]]) %>% stringr::str_squish()) %>% tidyr::separate(.data[["Score"]], into = c("HomeGoals", "AwayGoals"), sep = " ") %>% dplyr::mutate(HomeGoals = as.numeric(.data[["HomeGoals"]]), AwayGoals = as.numeric(.data[["AwayGoals"]]), From 01ae55aff6aa2ca04210d1bea8de60bd956a5d5e Mon Sep 17 00:00:00 2001 From: Tony ElHabr Date: Sat, 4 Nov 2023 16:55:19 -0500 Subject: [PATCH 2/2] use unicode character --- R/get_match_results.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/get_match_results.R b/R/get_match_results.R index 524b4f94..7e42654b 100644 --- a/R/get_match_results.R +++ b/R/get_match_results.R @@ -83,7 +83,7 @@ suppressWarnings( season_summary <- season_summary %>% dplyr::filter(is.na(.data[["Time"]]) | .data[["Time"]] != "Time") %>% - dplyr::mutate(Score = gsub("–", " ", .data[["Score"]]) %>% stringr::str_squish()) %>% + dplyr::mutate(Score = gsub("\u2013", " ", .data[["Score"]]) %>% stringr::str_squish()) %>% tidyr::separate(.data[["Score"]], into = c("HomeGoals", "AwayGoals"), sep = " ") %>% dplyr::mutate(HomeGoals = as.numeric(.data[["HomeGoals"]]), AwayGoals = as.numeric(.data[["AwayGoals"]]),