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

arguments imply differing number of rows #127

Closed
pacoca43 opened this issue Jun 1, 2022 · 8 comments
Closed

arguments imply differing number of rows #127

pacoca43 opened this issue Jun 1, 2022 · 8 comments

Comments

@pacoca43
Copy link

pacoca43 commented Jun 1, 2022

Hi, I am trying to scrap players data from Transfermarkt and I get this error on certain teams. For example, when I try to do it with Dortmund. I don't know how to fix it. Thanks

in data.frame(X1 = c("player_valuation", "max_player_valuation", :
arguments imply differing number of rows: 3, 0

@JaseZiv
Copy link
Owner

JaseZiv commented Jun 1, 2022

Hi,

Can you please provide the full code used that leads to the error. Also, the output of sessionInfo()

@pacoca43
Copy link
Author

pacoca43 commented Jun 2, 2022

Thank you for your answer. This is the full code:

library(worldfootballR)
segunda_esp_teams <- tm_league_team_urls(start_year = 2021, league_url = "https://www.transfermarkt.es/laliga2/startseite/wettbewerb/ES2")
segunda_esp_teams

almeria_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/ud-almeria/startseite/verein/3302/saison_id/2021")
ALM_bios<- tm_player_bio(player_urls = almeria_pl_bios)
write.csv(x=ALM_bios, file = "BIOS EQUIPOS/2ESP/ALM_bios.csv", row.names = FALSE)

valladolid_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/real-valladolid/startseite/verein/366/saison_id/2021")
VAL_bios<- tm_player_bio(player_urls = valladolid_pl_bios)
write.csv(x=VAL_bios, file = "BIOS EQUIPOS/2ESP/VAL_bios.csv", row.names = FALSE)

leganes_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/cd-leganes/startseite/verein/1244/saison_id/2021")
LEG_bios<- tm_player_bio(player_urls = leganes_pl_bios)
write.csv(x=LEG_bios, file = "BIOS EQUIPOS/2ESP/LEG_bios.csv", row.names = FALSE)

rsoc_b_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/real-sociedad-b/startseite/verein/9899/saison_id/2021")
SOB_bios<- tm_player_bio(player_urls = rsoc_b_pl_bios)
write.csv(x=SOB_bios, file = "BIOS EQUIPOS/2ESP/SOB_bios.csv", row.names = FALSE)

eibar_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/sd-eibar/startseite/verein/1533/saison_id/2021")
EIB_bios<- tm_player_bio(player_urls = eibar_pl_bios)
write.csv(x=EIB_bios, file = "BIOS EQUIPOS/2ESP/EIB_bios.csv", row.names = FALSE)

huesca_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/sd-huesca/startseite/verein/5358/saison_id/2021")
HUE_bios<- tm_player_bio(player_urls = huesca_pl_bios)
write.csv(x=HUE_bios, file = "BIOS EQUIPOS/2ESP/HUE_bios.csv", row.names = FALSE)

sporting_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/sporting-gijon/startseite/verein/2448/saison_id/2021")
SPO_bios<- tm_player_bio(player_urls = sporting_pl_bios)
write.csv(x=SPO_bios, file = "BIOS EQUIPOS/2ESP/SPO_bios.csv", row.names = FALSE)

girona_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/fc-girona/startseite/verein/12321/saison_id/2021")
GIR_bios<- tm_player_bio(player_urls = girona_pl_bios)
write.csv(x=GIR_bios, file = "BIOS EQUIPOS/2ESP/GIR_bios.csv", row.names = FALSE)

zaragoza_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/real-saragossa/startseite/verein/142/saison_id/2021")
ZAR_bios<- tm_player_bio(player_urls = zaragoza_pl_bios)
write.csv(x=ZAR_bios, file = "BIOS EQUIPOS/2ESP/ZAR_bios.csv", row.names = FALSE)

malaga_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/fc-malaga/startseite/verein/1084/saison_id/2021")
MAL_bios<- tm_player_bio(player_urls = malaga_pl_bios)
write.csv(x=MAL_bios, file = "BIOS EQUIPOS/2ESP/MAL_bios.csv", row.names = FALSE)

laspalmas_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/ud-las-palmas/startseite/verein/472/saison_id/2021")
LPA_bios<- tm_player_bio(player_urls = laspalmas_pl_bios)
write.csv(x=LPA_bios, file = "BIOS EQUIPOS/2ESP/LPA_bios.csv", row.names = FALSE)

mirandes_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/cd-mirandes/startseite/verein/13222/saison_id/2021")
MIR_bios<- tm_player_bio(player_urls = mirandes_pl_bios)
write.csv(x=MIR_bios, file = "BIOS EQUIPOS/2ESP/MIR_bios.csv", row.names = FALSE)

tenerife_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/cd-teneriffa/startseite/verein/648/saison_id/2021")
TER_bios<- tm_player_bio(player_urls = tenerife_pl_bios)
write.csv(x=TER_bios, file = "BIOS EQUIPOS/2ESP/TER_bios.csv", row.names = FALSE)

oviedo_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/real-oviedo/startseite/verein/2497/saison_id/2021")
OVI_bios<- tm_player_bio(player_urls = oviedo_pl_bios)
write.csv(x=OVI_bios, file = "BIOS EQUIPOS/2ESP/OVI_bios.csv", row.names = FALSE)

fuenlabrada_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/fc-fuenlabrada/startseite/verein/16486/saison_id/2021")
FUE_bios<- tm_player_bio(player_urls = fuenlabrada_pl_bios)
write.csv(x=FUE_bios, file = "BIOS EQUIPOS/2ESP/FUE_bios.csv", row.names = FALSE)

ponfe_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/sd-ponferradina/startseite/verein/4032/saison_id/2021")
PON_bios<- tm_player_bio(player_urls = ponfe_pl_bios)
write.csv(x=PON_bios, file = "BIOS EQUIPOS/2ESP/PON_bios.csv", row.names = FALSE)

cartagena_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/fc-cartagena/startseite/verein/7077/saison_id/2021")
CAR_bios<- tm_player_bio(player_urls = cartagena_pl_bios)
write.csv(x=CAR_bios, file = "BIOS EQUIPOS/2ESP/CAR_bios.csv", row.names = FALSE)

ibiza_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/ud-ibiza/startseite/verein/13241/saison_id/2021")
IBI_bios<- tm_player_bio(player_urls = ibiza_pl_bios)
write.csv(x=IBI_bios, file = "BIOS EQUIPOS/2ESP/IBI_bios.csv", row.names = FALSE)

amorebieta_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/sd-amorebieta/startseite/verein/16575/saison_id/2021")
AMO_bios<- tm_player_bio(player_urls = amorebieta_pl_bios)
write.csv(x=AMO_bios, file = "BIOS EQUIPOS/2ESP/AMO_bios.csv", row.names = FALSE)

burgos_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/burgos-cf/startseite/verein/1536/saison_id/2021")
BUR_bios<- tm_player_bio(player_urls = burgos_pl_bios)
write.csv(x=BUR_bios, file = "BIOS EQUIPOS/2ESP/BUR_bios.csv", row.names = FALSE)

lugo_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/cd-lugo/startseite/verein/11000/saison_id/2021")
LUG_bios<- tm_player_bio(player_urls = lugo_pl_bios)
write.csv(x=LUG_bios, file = "BIOS EQUIPOS/2ESP/LUG_bios.csv", row.names = FALSE)

alcorocon_pl_bios<- tm_team_player_urls("https://www.transfermarkt.com/ad-alcorcon/startseite/verein/11596/saison_id/2021")
ALC_bios<- tm_player_bio(player_urls = alcorocon_pl_bios)
write.csv(x=ALC_bios, file = "BIOS EQUIPOS/2ESP/ALC_bios.csv", row.names = FALSE)

In this case, 'MAL_bios', 'FUE_bios' and 'IBI_bios' return "arguments imply differing number of rows: 3, 0" as an error.

There is also something very strange in the case of MAL_bios. The results returned are those of a team called Mallorca (https://www.transfermarkt.com/rcd-mallorca/startseite/verein/237/saison_id=2021) not Malaga (https://www.transfermarkt.com/fc-malaga/startseite/verein/1084/saison_id/2021).
Thanks again

@pacoca43
Copy link
Author

pacoca43 commented Jun 2, 2022

Hi, again.
I have just checked that there are other cases of clubs where the data extracted does not correspond to the requested team, but to another one with a very similar name.
These are the cases, in addition to the one mentioned above:

Thanks

@JaseZiv
Copy link
Owner

JaseZiv commented Jun 2, 2022

Hmmm this is interesting. I am unable to recreate the errors you're experiencing.

When I run the following:

library(worldfootballR)
library(tidyverse)

wolves_url <- tm_team_player_urls("https://www.transfermarkt.com/wolverhampton-wanderers/startseite/verein/543/saison_id/2021")
wolves_bios<- tm_player_bio(player_urls = wolves_url)

I get the correct results (as in payers for Wolverhampton, not Wolfsburg:
image

As for the other errors, I can't recreate them either, with the code you provided not returning a single error.

Can you please tell me what you see when you run sessionInfo() in the console?

@pacoca43
Copy link
Author

pacoca43 commented Jun 2, 2022

sessionInfo()
R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=Spanish_Spain.utf8 LC_CTYPE=Spanish_Spain.utf8 LC_MONETARY=Spanish_Spain.utf8
[4] LC_NUMERIC=C LC_TIME=Spanish_Spain.utf8

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

other attached packages:
[1] installr_0.23.2 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.9 purrr_0.3.4
[6] readr_2.1.2 tidyr_1.2.0 tibble_3.1.7 ggplot2_3.3.6 tidyverse_1.3.1
[11] worldfootballR_0.5.2

loaded via a namespace (and not attached):
[1] cellranger_1.1.0 pillar_1.7.0 compiler_4.2.0 dbplyr_2.1.1 prettyunits_1.1.1 tools_4.2.0
[7] progress_1.2.2 gtable_0.3.0 lubridate_1.8.0 jsonlite_1.8.0 lifecycle_1.0.1 pkgconfig_2.0.3
[13] rlang_1.0.2 reprex_2.0.1 rstudioapi_0.13 cli_3.3.0 DBI_1.1.2 curl_4.3.2
[19] haven_2.5.0 withr_2.5.0 httr_1.4.3 janitor_2.1.0 xml2_1.3.3 fs_1.5.2
[25] generics_0.1.2 vctrs_0.4.1 hms_1.1.1 grid_4.2.0 tidyselect_1.1.2 snakecase_0.11.0
[31] glue_1.6.2 R6_2.5.1 fansi_1.0.3 readxl_1.4.0 modelr_0.1.8 tzdb_0.3.0
[37] selectr_0.4-2 magrittr_2.0.3 scales_1.2.0 backports_1.4.1 ellipsis_0.3.2 assertthat_0.2.1
[43] rvest_1.0.2 colorspace_2.0-3 utf8_1.2.2 stringi_1.7.6 munsell_0.5.0 broom_0.8.0

@JaseZiv
Copy link
Owner

JaseZiv commented Jun 4, 2022

I'm not too sure why you're getting these errors unfortunately...

I will leave this issue open in the hope that anyone else with this problem has come up with a solution.

@pacoca43
Copy link
Author

pacoca43 commented Jun 4, 2022

Thank you very much

@IgorCersosimo
Copy link

Hi,
I get the same error with a different function.
I am writing about it here instead of opening a new issue and I hope it's OK.

Here a reproducible call:
player_transfer_history("https://www.transfermarkt.com/massimiliano-allegri/profil/spieler/163501")

If I understand correctly, the problem is that the function looks for a css tag (.tm-player-transfer-history-grid__flag) that cannot be found on the first row of the table, which reports that the player is retired.

The code fails to get the information, but does not track the error and instead returns a character(0).
This leads to an incorrect number of information when building the data.frame object.

I also noticed that the function does not return any nationality when the alt attribute is missing.
This could maybe be fixed by matching the flag image to a nation (just an idea).

I hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants