Skip to content

Commit

Permalink
address #336 and #338
Browse files Browse the repository at this point in the history
  • Loading branch information
JaseZiv committed Nov 2, 2023
1 parent 9ca8d3f commit 6f6711c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 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.4.0009
Version: 0.6.4.0010
Authors@R: c(
person("Jason", "Zivkovic", , "[email protected]", role = c("aut", "cre", "cph")),
person("Tony", "ElHabr", , "[email protected]", role = "ctb"),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* `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)


### Improvements
* `fb_player_season_stats()` now includes the ability to get a player's national team stats [https://github.com/JaseZiv/worldfootballR/pull/310/files] (0.6.4.0002)
Expand Down
8 changes: 4 additions & 4 deletions R/player_market_values.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ tm_player_market_values <- function(country_name, start_year, league_url = NA) {
player_num <- NA_character_
}
# player names
player_name <- team_data %>% rvest::html_nodes(".hauptlink a") %>% rvest::html_text() %>% stringr::str_squish()
player_name <- team_data %>% rvest::html_nodes(".inline-table a") %>% rvest::html_text() %>% stringr::str_squish()
if(length(player_name) == 0) {
player_name <- NA_character_
}
# player_url
player_url <- team_data %>% rvest::html_nodes(".hauptlink a") %>% rvest::html_attr("href") %>%
player_url <- team_data %>% rvest::html_nodes(".inline-table a") %>% rvest::html_attr("href") %>%
paste0(main_url, .)
if(length(player_url) == 0) {
player_url <- NA_character_
Expand Down Expand Up @@ -220,12 +220,12 @@ tm_player_market_values <- function(country_name, start_year, league_url = NA) {
dplyr::left_join(all_seasons_df, by = "season_urls")


all_seasons_df <- all_seasons_df %>%
aa <- all_seasons_df %>%
dplyr::mutate(player_market_value_euro = mapply(.convert_value_to_numeric, player_market_value)) %>%
dplyr::mutate(date_joined = .tm_fix_dates(.data[["date_joined"]]),
contract_expiry = .tm_fix_dates(.data[["contract_expiry"]])) %>%
tidyr::separate(., player_birthday, into = c("Month", "Day", "Year"), sep = " ", remove = F) %>%
dplyr::mutate(player_age = sub(".*(?:\\((.*)\\)).*|.*", "\\1", .data[["Year"]]),
dplyr::mutate(player_age = gsub(".*\\(", "", .data[["player_birthday"]]) %>% gsub("\\)", "", .),
Day = gsub(",", "", .data[["Day"]]) %>% as.numeric(),
Year = as.numeric(gsub("\\(.*", "", .data[["Year"]])),
Month = match(.data[["Month"]], month.abb),
Expand Down

0 comments on commit 6f6711c

Please sign in to comment.