Closed christianlohr9 closed 2 years ago
Thanks for raising this.
Interesting... @tonyelhabr have you got any idea what might be happening here?
ah, there was an issue. the code was doing this
dplyr::mutate(rows, stats = list(stats))
when it really just needed to do this
rows$stats <- stats
seems like the fix works
library(tidyverse)
#> Warning: package 'tidyr' was built under R version 4.1.2
#> Warning: package 'readr' was built under R version 4.1.2
library(worldfootballR)
## schalke 04 match
players <- fotmob_get_match_players(3625000)
bulter <- players %>% filter(id == "626890")
bulter %>%
select(player_id = id, stats) %>%
unnest(stats)
#> # A tibble: 1 x 34
#> player_id stats_fot_mob_rating stats_minutes_played stats_saves stats_goals
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 626890 7.11 82 NA 0
#> # ... with 29 more variables: stats_goals_conceded <dbl>,
#> # stats_diving_save <dbl>, stats_saves_inside_box <dbl>,
#> # stats_acted_as_sweeper <dbl>, stats_punches <dbl>, stats_throws <dbl>,
#> # stats_high_claim <dbl>, stats_recoveries <dbl>, stats_touches <dbl>,
#> # stats_assists <dbl>, stats_total_shots <dbl>, stats_key_passes <dbl>,
#> # stats_corners <dbl>, stats_dispossessed <dbl>, stats_blocks <dbl>,
#> # stats_clearances <dbl>, stats_headed_clearance <dbl>, ...
## another player from the match
terodde <- players %>% filter(id == "95095")
terodde %>%
select(player_id = id, stats) %>%
unnest(stats)
#> # A tibble: 1 x 34
#> player_id stats_fot_mob_rating stats_minutes_played stats_saves stats_goals
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 95095 7.17 90 NA 0
#> # ... with 29 more variables: stats_goals_conceded <dbl>,
#> # stats_diving_save <dbl>, stats_saves_inside_box <dbl>,
#> # stats_acted_as_sweeper <dbl>, stats_punches <dbl>, stats_throws <dbl>,
#> # stats_high_claim <dbl>, stats_recoveries <dbl>, stats_touches <dbl>,
#> # stats_assists <dbl>, stats_total_shots <dbl>, stats_key_passes <dbl>,
#> # stats_corners <dbl>, stats_dispossessed <dbl>, stats_blocks <dbl>,
#> # stats_clearances <dbl>, stats_headed_clearance <dbl>, ...
## check that shotmap still works
liv_matches <- c(3609994, 3610132)
liv_players <- fotmob_get_match_players(liv_matches)
salah <- liv_players %>% filter(id == "292462")
salah %>%
select(player_id = id, shotmap) %>%
unnest(shotmap)
#> # A tibble: 7 x 23
#> player_id id eventType teamId playerId playerName x y min
#> <chr> <dbl> <chr> <int> <int> <chr> <dbl> <dbl> <int>
#> 1 292462 2338869639 AttemptSaved 8650 292462 Mohamed S~ 92.5 50.7 8
#> 2 292462 2338938757 AttemptSaved 8650 292462 Mohamed S~ 80.6 45.3 63
#> 3 292462 2338947917 Goal 8650 292462 Mohamed S~ 102. 24.3 76
#> 4 292462 2371191153 AttemptSaved 8650 292462 Mohamed S~ 90 33.3 6
#> 5 292462 2371199193 Goal 8650 292462 Mohamed S~ 101. 24.1 26
#> 6 292462 2371200791 AttemptSaved 8650 292462 Mohamed S~ 91.7 29.5 36
#> 7 292462 2371208775 AttemptSaved 8650 292462 Mohamed S~ 77.5 42.2 57
#> # ... with 14 more variables: minAdded <lgl>, isBlocked <lgl>,
#> # isOnTarget <lgl>, blockedX <dbl>, blockedY <dbl>, goalCrossedY <dbl>,
#> # goalCrossedZ <dbl>, expectedGoals <dbl>, expectedGoalsOnTarget <dbl>,
#> # shotType <chr>, situation <chr>, period <chr>, isOwnGoal <lgl>,
#> # onGoalShot <df[,3]>
Created on 2022-03-19 by the reprex package (v2.0.1)
i'll submit a fix
This has been resolved in v0.4.10.4000
Hello, where is v0.4.10.4000
available? Actually I donwload it from @head in this repo, but stills being v0.4.10.3000
If you just install the current dev version (v0.4.10.5000), that is basically vv0.4.10.4000 with one extra function.
Hope that helps?
On Tue, 22 Mar 2022 at 10:33, Roman Alberto Velez Jimenez < @.***> wrote:
Hello, where is v0.4.10.4000 available? Actually I donwload it from @Head https://github.com/Head in this repo, but stills being v0.4.10.3000
— Reply to this email directly, view it on GitHub https://github.com/JaseZiv/worldfootballR/issues/98#issuecomment-1074525406, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHQDRJYNITTUBKYFJU4DBJLVBEBMVANCNFSM5Q7CV55Q . You are receiving this because you modified the open/close state.Message ID: @.***>
Thank you very much for this quick fix! ❤️
I pretty much assume this is on me, but I still get the two rows, even after installing 0.4.10.5000... Any chance you see something that I'm missing? 🙈
library(worldfootballR)
sessionInfo()
#> R version 4.0.4 (2021-02-15)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 18363)
#>
#> Matrix products: default
#>
#> locale:
#> [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252
#> [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
#> [5] LC_TIME=German_Germany.1252
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] worldfootballR_0.4.10.5000
#>
#> loaded via a namespace (and not attached):
#> [1] pillar_1.7.0 compiler_4.0.4 highr_0.9 tools_4.0.4
#> [5] digest_0.6.29 lubridate_1.8.0 jsonlite_1.8.0 evaluate_0.15
#> [9] lifecycle_1.0.1 tibble_3.1.6 pkgconfig_2.0.3 rlang_1.0.2
#> [13] reprex_2.0.1 cli_3.2.0 DBI_1.1.2 rstudioapi_0.13
#> [17] yaml_2.3.5 xfun_0.30 fastmap_1.1.0 xml2_1.3.3
#> [21] httr_1.4.2 withr_2.5.0 dplyr_1.0.8 stringr_1.4.0
#> [25] knitr_1.37 janitor_2.1.0 hms_1.1.1 generics_0.1.2
#> [29] fs_1.5.2 vctrs_0.3.8 tidyselect_1.1.2 glue_1.6.2
#> [33] snakecase_0.11.0 R6_2.5.1 fansi_1.0.2 rmarkdown_2.13
#> [37] tidyr_1.2.0 tzdb_0.2.0 readr_2.1.2 purrr_0.3.4
#> [41] magrittr_2.0.2 ellipsis_0.3.2 htmltools_0.5.2 rvest_1.0.2
#> [45] assertthat_0.2.1 utf8_1.2.2 stringi_1.7.6 crayon_1.5.0
Created on 2022-03-22 by the reprex package (v2.0.1)
Here the output (basically the same as in the original issue):
library(tidyverse)
#> Warning: Paket 'tidyverse' wurde unter R Version 4.0.5 erstellt
#> Warning: Paket 'ggplot2' wurde unter R Version 4.0.5 erstellt
#> Warning: Paket 'tibble' wurde unter R Version 4.0.5 erstellt
#> Warning: Paket 'tidyr' wurde unter R Version 4.0.5 erstellt
#> Warning: Paket 'readr' wurde unter R Version 4.0.5 erstellt
#> Warning: Paket 'dplyr' wurde unter R Version 4.0.5 erstellt
library(worldfootballR)
players <- fotmob_get_match_players(3625000)
bulter <- players %>% filter(id == "626890")
bulter %>%
select(player_id = id, stats) %>%
unnest(stats)
#> # A tibble: 2 x 17
#> player_id stats_fot_mob_rating stats_minutes_played stats_goals stats_assists
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 626890 7.11 82 0 0
#> 2 626890 7.17 90 0 0
#> # ... with 12 more variables: stats_total_shots <dbl>, stats_key_passes <dbl>,
#> # stats_blocked_shots <dbl>, stats_touches <dbl>, stats_dispossessed <dbl>,
#> # stats_clearances <dbl>, stats_headed_clearance <dbl>,
#> # stats_recoveries <dbl>, stats_dribbled_past <dbl>, stats_was_fouled <dbl>,
#> # stats_fouls_committed <dbl>, stats_big_chance_missed <dbl>
Created on 2022-03-22 by the reprex package (v2.0.1)
@christianlohr9 Can you try again? The latest version (0.5.0) should have the fix. We got a little out of sorts with merging changes, so the stats bug wasn't fixed until after your latest message.
Yes, it works! Thank you so much! ❤️
Hi,
I want to get stats from a player and I'm always getting some kinda buggy output with many rows for a single game when using
fotmob_get_match_players
andtidyr::unnest(stats)
. It's like you get in your stats example with Salah (https://jaseziv.github.io/worldfootballR/articles/extract-fotmob-data.html). You get 6 rows for only 2 matchups.I tried it with some random matchups in random leagues and always get that buggy output. For example I tried it with a matchup of the 2. Bundesliga from last week. The player gets 2 rows output. He was exchanged in minute 82 so that row seems correct. The other one has to be some row of another player, because I checked the whole players performances and theres none that references to that 7.17 rating.
That really confuses me :S
Created on 2022-03-17 by the reprex package (v2.0.1)
Many thanks in advance for your support, appreciate the work!
Best regards, Christian