Skip to content
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

tm_player_market_values() returning names and valuations on separate lines for player_name #338

Closed
JaseZiv opened this issue Nov 1, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@JaseZiv
Copy link
Owner

JaseZiv commented Nov 1, 2023

tm_player_market_values() returned results have extra rows where the player_name is filled with the price of the previous player. All the other information is like shifted and we obtain for example (see below) that Zack Steffen is a Centre-Back from Portugal playing as Man City number 3.

library(worldfootballR) # ‘0.6.4.9’
tm_player_market_values(country_name = "England", start_year = 2022)
#>
        comp_name region country season_start_year           squad player_num         player_name    player_position player_dob player_age player_nationality
1  Premier League Europe England              2022 Manchester City         31             Ederson         Goalkeeper 1993-08-17         NA             Brazil
2  Premier League Europe England              2022 Manchester City         18             €40.00m         Goalkeeper 1992-11-06         NA            Germany
3  Premier League Europe England              2022 Manchester City          -       Stefan Ortega         Goalkeeper 1995-04-02         NA      United States
4  Premier League Europe England              2022 Manchester City         33              €9.00m         Goalkeeper 1985-09-03         NA            England
5  Premier League Europe England              2022 Manchester City          3        Zack Steffen        Centre-Back 1997-05-14         NA           Portugal
6  Premier League Europe England              2022 Manchester City          6              €3.50m        Centre-Back 1995-02-18         NA        Netherlands
7  Premier League Europe England              2022 Manchester City          5        Scott Carson        Centre-Back 1994-05-28         NA            England
8  Premier League Europe England              2022 Manchester City         25               €200k        Centre-Back 1995-07-19         NA        Switzerland
9  Premier League Europe England              2022 Manchester City         14          Rúben Dias        Centre-Back 1994-05-27         NA              Spain
10 Premier League Europe England              2022 Manchester City          -             €80.00m        Centre-Back 2003-09-18         NA            England
11 Premier League Europe England              2022 Manchester City         21          Nathan Aké          Left-Back 2000-09-04         NA              Spain
12 Premier League Europe England              2022 Manchester City          -             €42.00m          Left-Back 2002-12-26         NA            England
@JaseZiv JaseZiv added the bug Something isn't working label Nov 1, 2023
@JaseZiv JaseZiv self-assigned this Nov 1, 2023
JaseZiv added a commit that referenced this issue Nov 2, 2023
@mcefis
Copy link

mcefis commented Nov 2, 2023

I had the same error. Thanks for what you could do for solving it.
Best

Mattia

@drasbaek
Copy link
Contributor

drasbaek commented Nov 3, 2023

@JaseZiv I don't know whether I should open a pull request when you have set this as self-assigned. But the bug seems to be fixed by adding td.posrela to the html_node as that will avoid picking all the hauptlink for euro values as well.

From

      # player names
      player_name <- team_data %>% rvest::html_nodes(".hauptlink a") %>% rvest::html_text() %>% stringr::str_squish()

To

      # player names
      player_name <- team_data %>% rvest::html_nodes("td.posrela .hauptlink a") %>% rvest::html_text() %>% stringr::str_squish()

@JaseZiv
Copy link
Owner Author

JaseZiv commented Nov 3, 2023

@JaseZiv I don't know whether I should open a pull request when you have set this as self-assigned. But the bug seems to be fixed by adding td.posrela to the html_node as that will avoid picking all the hauptlink for euro values as well.

From


      # player names

      player_name <- team_data %>% rvest::html_nodes(".hauptlink a") %>% rvest::html_text() %>% stringr::str_squish()

To


      # player names

      player_name <- team_data %>% rvest::html_nodes("td.posrela .hauptlink a") %>% rvest::html_text() %>% stringr::str_squish()

Thanks. I have already created a PR to address this. Just waiting on an approval from @tonyelhabr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants