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

Error in fotmob_get_match_details() #271

Closed samuelMyrbo closed 1 year ago

samuelMyrbo commented 1 year ago

Trying to get match shooting-locations from fotmob using fotmob_get_match_details() using this code:

match_details <- fotmob_get_match_details(4077010) match_details

getting this error:

match_details <- fotmob_get_match_details(4077010) Error: arguments imply differing number of rows: 1, 0 > match_details A tibble: 0 x 1 # ... with 1 variable: match_id i Use colnames() to see all variable names

tonyelhabr commented 1 year ago

Fixed in the newest version of the package. (You can update it with remotes::install_github("JaseZiv/worldfootballR"). )

suppressPackageStartupMessages(suppressWarnings({
  library(worldfootballR)
  library(dplyr)
}))

packageVersion("worldfootballR")
#> [1] '0.6.3.1'
dplyr::glimpse(fotmob_get_match_details(4077010))
#> Rows: 24
#> Columns: 42
#> $ match_id                 <int> 4077010, 4077010, 4077010, 4077010, 4077010, …
#> $ match_round              <chr> "2", "2", "2", "2", "2", "2", "2", "2", "2", …
#> $ league_id                <int> 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 5…
#> $ league_name              <chr> "Eliteserien", "Eliteserien", "Eliteserien", …
#> $ league_round_name        <chr> "Round 2", "Round 2", "Round 2", "Round 2", "…
#> $ parent_league_id         <int> 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 5…
#> $ parent_league_season     <chr> "2023", "2023", "2023", "2023", "2023", "2023…
#> $ match_time_utc           <chr> "Sun, Apr 16, 2023, 15:00 UTC", "Sun, Apr 16,…
#> $ home_team_id             <int> 8512, 8512, 8512, 8512, 8512, 8512, 8512, 851…
#> $ home_team                <chr> "FK Haugesund", "FK Haugesund", "FK Haugesund…
#> $ home_team_color          <chr> "#003070", "#003070", "#003070", "#003070", "…
#> $ away_team_id             <int> 8448, 8448, 8448, 8448, 8448, 8448, 8448, 844…
#> $ away_team                <chr> "Hamarkameratene", "Hamarkameratene", "Hamark…
#> $ away_team_color          <chr> "#009040", "#009040", "#009040", "#009040", "…
#> $ id                       <dbl> 2534676081, 2534687199, 2534689341, 253468936…
#> $ event_type               <chr> "Miss", "AttemptSaved", "Miss", "AttemptSaved…
#> $ team_id                  <int> 8448, 8448, 8512, 8512, 8448, 8448, 8448, 844…
#> $ player_id                <int> 836458, 537187, 742396, 868705, 741418, 20008…
#> $ player_name              <chr> "Oliver Kjærgaard", "Kristian Lønstad Onsrud"…
#> $ x                        <dbl> 90.80000, 85.70882, 94.00000, 97.47368, 94.67…
#> $ y                        <dbl> 43.79057, 40.30143, 27.69857, 46.31287, 31.94…
#> $ min                      <int> 5, 18, 20, 20, 22, 22, 23, 24, 25, 29, 41, 45…
#> $ min_added                <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0…
#> $ is_blocked               <lgl> FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, …
#> $ is_on_target             <lgl> FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, T…
#> $ blocked_x                <dbl> NA, 89.70000, 100.54310, 104.33621, 96.89474,…
#> $ blocked_y                <dbl> NA, 39.29286, 41.77250, 34.38125, 32.62750, 3…
#> $ goal_crossed_y           <dbl> 46.10268, 35.98250, 52.54854, 32.62750, 35.14…
#> $ goal_crossed_z           <dbl> 0.89252631, 1.21999999, 0.08989474, 0.9374736…
#> $ expected_goals           <dbl> 0.06069348, 0.03136442, 0.04637458, 0.0821640…
#> $ expected_goals_on_target <dbl> NA, NA, NA, 0.0928, NA, NA, NA, NA, NA, NA, N…
#> $ shot_type                <chr> "LeftFoot", "RightFoot", "Header", "LeftFoot"…
#> $ situation                <chr> "ThrowInSetPiece", "RegularPlay", "RegularPla…
#> $ period                   <chr> "FirstHalf", "FirstHalf", "FirstHalf", "First…
#> $ is_own_goal              <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FAL…
#> $ on_goal_shot_x           <dbl> 0.000000e+00, 4.755291e-01, 0.000000e+00, 1.3…
#> $ on_goal_shot_y           <dbl> 0.073746201, 0.322751321, 0.004846460, 0.2480…
#> $ on_goal_shot_zoom_ratio  <dbl> 0.3123276, 1.0000000, 0.2037897, 1.0000000, 1…
#> $ first_name               <chr> "Oliver", "Kristian Lønstad", "Sondre", "Osca…
#> $ last_name                <chr> "Kjærgaard", "Onsrud", "Liseth", "Krusnell", …
#> $ full_name                <chr> "Oliver Kjærgaard", "Kristian Lønstad Onsrud"…
#> $ team_color               <chr> "#009040", "#009040", "#003070", "#003070", "…
tomthomas commented 1 year ago

Still an issue.

tonyelhabr commented 1 year ago

Still an issue.

What version of the package do you have? I just tried the reprex and get the same results, with packageVersion("worldfootballR") = 0.6.3.3

tomthomas commented 1 year ago

What version of the package do you have? I just tried the reprex and get the same results, with packageVersion("worldfootballR") = 0.6.3.3

I believe I maybe on CRAN version, not dev. whichever is 0.6.2.9400

tomthomas commented 1 year ago

Non-issue. It was due to an installation issue. Working for me now.

tonyelhabr commented 1 year ago

Cool. Unfortunately, the fotmob API changes pretty often, and we don't want to have to re-publish the package to CRAN for every minor change.