JaseZiv / worldfootballR

A wrapper for extracting world football (soccer) data from FBref, Transfermark, Understat
https://jaseziv.github.io/worldfootballR/
433 stars 59 forks source link

fotmob_get_match_momentum causes error #308

Closed dammfoolman closed 11 months ago

dammfoolman commented 11 months ago

{{Brief description of the problem}}

fotmob_get_match_momentum causes error for example

fotmob_get_match_momentum(4222421)

Error in map(): ℹ In index: 1. ℹ With name: 4222421. Caused by error in tidyr::unnest(): ! Can't subset columns that don't exist. ✖ Column data doesn't exist.

sessionInfo() R version 4.2.2 (2022-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 22621)

Matrix products: default

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

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

other attached packages: [1] worldfootballR_0.6.3.0003 tidyr_1.3.0

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 lubridate_1.9.2 jsonlite_1.8.5 lifecycle_1.0.3
[9] tibble_3.2.1 timechange_0.2.0 pkgconfig_2.0.3 rlang_1.1.0 cli_3.6.1 rstudioapi_0.14 curl_5.0.0 withr_2.5.0
[17] abettor_0.1.7 dplyr_1.1.2.9000 httr_1.4.5 stringr_1.5.0 janitor_2.2.0 xml2_1.3.3 generics_0.1.3 vctrs_0.6.2
[25] hms_1.1.2 grid_4.2.2 tidyselect_1.2.0 snakecase_0.11.0 glue_1.6.2 R6_2.5.1 fansi_1.0.4 purrr_1.0.1
[33] readr_2.1.4 tzdb_0.4.0 magrittr_2.0.3 ellipsis_0.3.2 rvest_1.0.3 utf8_1.2.3 stringi_1.7.12 crayon_1.5.2

francescozonaro commented 11 months ago

Working fine for me with

R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)
worldfootballR_0.6.3.0013
dammfoolman commented 11 months ago

still not working for me .. installed the same environment as above

fotmob_get_match_momentum(4202251) Error in map(): ℹ In index: 1. ℹ With name: 4202251. Caused by error in tidyr::unnest(): ! Can't subset columns that don't exist. ✖ Column data doesn't exist. Run rlang::last_trace() to see where the error occurred.

image

francescozonaro commented 11 months ago

My bad man, didn't see you were using a Championship match. The problem seems to be in the .fotmob_get_single_match_momentum function

momentum <- resp$result$content$momentum
main <- tidyr::unnest(dplyr::bind_rows(momentum$main), "data")
main$type <- "main"
alt <-tidyr::unnest(dplyr::bind_rows(momentum$alternateModels), "data")
alt$type <- "alternateModels"
res <- dplyr::bind_rows(
  main,
  alt
)

the main momentum data is present, but the alternative momentum data isn't calculated for championship matches.

The fix should be rather easy, I'll try to send a PR to fix this as soon as I can

JaseZiv commented 11 months ago

Closing this due to Fotmob functions no longer included in worldfootballR