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_team_transfers() returns wrong leagues for past seasons #335

Open
drasbaek opened this issue Oct 16, 2023 · 1 comment
Open

tm_team_transfers() returns wrong leagues for past seasons #335

drasbaek opened this issue Oct 16, 2023 · 1 comment
Labels
for future consideration Issue is only minor and may be addressed in the future

Comments

@drasbaek
Copy link
Contributor

The tm_team_transfers(team_url, transfer_window = "all") function returns the team's current league rather than the one the team played in, in the given season.

For example:

# get transfers from Luton Town in 2018 (played in League One)
tm_team_transfers("https://www.transfermarkt.com/luton-town/startseite/verein/1031/saison_id/2018", transfer_window = "all")

Gives the correct transfers for the season but not the correct league for each row (Is Premier League, should be League One)

| #   | Team Name   | League          | Country | Season | Transfer Type | Player Name        | Player URL                                      | Player Position    | Player Age |
| --- | ----------- | --------------- | ------- | ------ | ------------- | ------------------ | ---------------------------------------------- | ------------------ | ---------- |
| 1   | Luton Town  | Premier League  | England | 2018   | Arrivals      | Andrew Shinnie     |https://www.transfermarkt.com/andrew-shinnie/profil/spieler/51733 | Attacking Midfield | 28         |
| 2   | Luton Town  | Premier League  | England | 2018   | Arrivals      | Sonny Bradley      |https://www.transfermarkt.com/sonny-bradley/profil/spieler/127794 | Centre-Back        | 26         |
| 3   | Luton Town  | Premier League  | England | 2018   | Arrivals      | Matty Pearson      |https://www.transfermarkt.com/matty-pearson/profil/spieler/121395 | Centre-Back        | 24         |
| 4   | Luton Town  | Premier League  | England | 2018   | Arrivals      | Eunan O'Kane       |https://www.transfermarkt.com/eunan-okane/profil/spieler/61583   | Central Midfield  | 28         |
| 5   | Luton Town  | Premier League  | England | 2018   | Arrivals      | Jorge Grant        |https://www.transfermarkt.com/jorge-grant/profil/spieler/334964 | Central Midfield  | 23         |
| 6   | Luton Town  | Premier League  | England | 2018   | Arrivals      | Kazenga LuaLua     |https://www.transfermarkt.com/kazenga-lualua/profil/spieler/52576 | Left Winger       | 27         |
| 7   | Luton Town  | Premier League  | England | 2018   | Arrivals      | Jack James         |https://www.transfermarkt.com/jack-james/profil/spieler/531863  | Right-Back        | 18         |
| 8   | Luton Town  | Premier League  | England | 2018   | Arrivals      | Luke Gambin        |https://www.transfermarkt.com/luke-gambin/profil/spieler/225121| Left Winger       | 26         |
| 9   | Luton Town  | Premier League  | England | 2018   | Arrivals      | Jake Jervis        |https://www.transfermarkt.com/jake-jervis/profil/spieler/129074  | Right Winger      | 27         |
| 10  | Luton Town  | Premier League  | England | 2018   | Arrivals      | Lloyd Jones        |https://www.transfermarkt.com/lloyd-jones/profil/spieler/244040 | Centre-Back       | 23         |
| ... | ...         | ...             | ...     | ...    | ...           | ...                | ...                                            | ...               | ...        |

Session info:

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] worldfootballR_0.6.4.0008

loaded via a namespace (and not attached):
 [1] pillar_1.9.0      compiler_4.2.2    prettyunits_1.1.1 tools_4.2.2       progress_1.2.2    digest_0.6.29     lubridate_1.9.2   jsonlite_1.8.4    evaluate_0.16    
[10] lifecycle_1.0.3   tibble_3.2.1      timechange_0.2.0  pkgconfig_2.0.3   rlang_1.1.0       cli_3.6.1         rstudioapi_0.15.0 yaml_2.3.5        xfun_0.32        
[19] fastmap_1.1.0     dplyr_1.1.1       httr_1.4.6        stringr_1.5.0     knitr_1.39        xml2_1.3.3        generics_0.1.3    vctrs_0.6.1       hms_1.1.3        
[28] tidyselect_1.2.0  glue_1.6.2        R6_2.5.1          fansi_1.0.4       rmarkdown_2.18    tidyr_1.3.0       purrr_1.0.1       readr_2.1.4       tzdb_0.3.0       
[37] magrittr_2.0.3    htmltools_0.5.3   rvest_1.0.3       utf8_1.2.3        stringi_1.7.8     crayon_1.5.2     
@JaseZiv
Copy link
Owner

JaseZiv commented Oct 31, 2023

Yeah this one is problematic... There's no real way around this other than introducing extra page loads to get the relevant league for that particular season... currently, the league is extracted from the relevant season's transfer page, but this league value is for the current league

image

Given transfermarkt page loads (and then scraping) is already pretty slow, I'm not overly keen on introducing additional page loads.

Will leave this open for now until a neater solution presents itself.

@JaseZiv JaseZiv added the for future consideration Issue is only minor and may be addressed in the future label Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for future consideration Issue is only minor and may be addressed in the future
Projects
None yet
Development

No branches or pull requests

2 participants