JaseZiv/worldfootballR

Issue with tm_squad_stats

jesbrz opened this issue · 3 comments

jesbrz commented

I'm using last development version.

If I use team_url = "https://www.transfermarkt.es/cf-rayo-majadahonda/leistungsdaten/verein/13702" and then df <- tm_squad_stats(team_url) I obtain the correct data.

But if I try the detailed view tab (with extended info like red and yellow cards or changes among other things) and change team_url to "https://www.transfermarkt.es/cf-rayo-majadahonda/leistungsdaten/verein/13702/reldata/%262023/plus/1", I obtain the same data that in normal view.

Am I doing anything wrong? Or is not possible to access this info?

Regardless the link you provide, that function will always scrape fixed specific data (basically, the normal view data). I don't think there is a function scraping yellow/reds from transfermarkt, but there may be something similar for fbref. Try this out

team_url <- "https://fbref.com/en/squads/fef8ad9e/Majadahonda-Stats"
df <- fb_team_player_stats(team_url, 'misc')

you could change the 'misc' parameter if you need other stats. This are all the stat types:

"standard", "shooting", "passing", "passing_types", "gca", "defense", "possession", "playing_time", "misc", "keeper", "keeper_adv"

jesbrz commented

Hi francescozonaro. The URL that you provide show data from 2022-2023 season, not for 2023-2024. Also, fbref not offers data for Spanish Primera Federacion league so only transfermarkt offers this info in the URL which I have indicated above. Thanks for your interest

Ah my bad, I saw one match played in both tables, didn't notice it was Copa del Rey (and a whole other year) on fbref!