sportsdataverse / wehoop

An R package to quickly obtain clean and tidy women's basketball play by play data.
https://wehoop.sportsdataverse.org/
Other
23 stars 2 forks source link

boxscore functions not returning any data #27

Closed tafamusoni closed 2 years ago

tafamusoni commented 2 years ago

The following function is not working and does not return any data. I am getting empty tibbles for any game id that I use, e.g., wehoop::wnba_boxscoreadvancedv2( 401391650, start_period = 0, end_period = 14, start_range = 0, end_range = 0, range_type = 0)

image

saiemgilani commented 2 years ago

My apologies for not seeing this somehow. So I believe the issue is that you are using the ESPN game_id values and that is resulting in the error. If you use the WNBA Stats API game_id's

 ## uses WNBA Stats API Game ID's (GAME_ID)
sched_wnba_stats_df <- wnba_leaguegamefinder(season=2022)$LeagueGameFinderResults
## uses ESPN Game IDs (game_id)
sched_espn_df <- load_wnba_schedule(2022)  

then figure out how to map your game_id and GAME_ID's together

wehoop::wnba_boxscoreadvancedv2(
1022200001,
start_period = 0,
end_period = 14,
start_range = 0,
end_range = 0,
range_type = 0)

> $PlayerStats
# A tibble: 22 × 32
   GAME_ID    TEAM_ID    TEAM_A…¹ TEAM_…² PLAYE…³ PLAYE…⁴ NICKN…⁵ START…⁶ COMMENT MIN   E_OFF…⁷ OFF_R…⁸ E_DEF…⁹ DEF_R…˟ E_NET…˟ NET_R…˟ AST_PCT AST_TOV
   <chr>      <chr>      <chr>    <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr> <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>  
 1 1042200202 1611661328 SEA      Seattle 203855  Stepha… Stepha… "F"     ""      32:35 89.6    92.2    109.2   108.1   -19.6   -15.9   0.158   3      
 2 1042200202 1611661328 SEA      Seattle 1627668 Breann… Breanna "F"     ""      38:33 94.9    95.9    100.9   102.8   -6      -6.8    0.2     1.5    
 3 1042200202 1611661328 SEA      Seattle 202250  Tina C… Tina    "C"     ""      30:57 95.3    95      105.8   101.7   -10.5   -6.7    0.077   0      
 4 1042200202 1611661328 SEA      Seattle 204319  Jewell… Jewell  "G"     ""      38:04 91      93.2    100.9   100     -9.9    -6.8    0.167   0      
 5 1042200202 1611661328 SEA      Seattle 100720  Sue Bi… Sue     "G"     ""      32:57 98.5    103.3   97.6    96.8    0.9     6.5     0.273   6      
 6 1042200202 1611661328 SEA      Seattle 202259  Epipha… Epipha… ""      ""      7:20  100     93.3    75.1    73.3    24.9    20      0       0      
 7 1042200202 1611661328 SEA      Seattle 1629496 Ezi Ma… Ezi     ""      ""      9:56  85.7    81.8    104     95.7    -18.3   -13.8   0       0      
 8 1042200202 1611661328 SEA      Seattle 201896  Briann… Briann  ""      ""      9:38  74.2    73.7    118.8   115.8   -44.6   -42.1   0.2     1      
 9 1042200202 1611661328 SEA      Seattle 202650  Jantel… Jantel  ""      "DNP -… NA    NA      0       NA      0       NA      0       NA      NA     
10 1042200202 1611661328 SEA      Seattle 1628920 Merced… Merced… ""      "DNP -… NA    NA      0       NA      0       NA      0       NA      NA     
# … with 12 more rows, 14 more variables: AST_RATIO <chr>, OREB_PCT <chr>, DREB_PCT <chr>, REB_PCT <chr>, TM_TOV_PCT <chr>, EFG_PCT <chr>,
#   TS_PCT <chr>, USG_PCT <chr>, E_USG_PCT <chr>, E_PACE <chr>, PACE <chr>, PACE_PER40 <chr>, POSS <chr>, PIE <chr>, and abbreviated variable names
#   ¹​TEAM_ABBREVIATION, ²​TEAM_CITY, ³​PLAYER_ID, ⁴​PLAYER_NAME, ⁵​NICKNAME, ⁶​START_POSITION, ⁷​E_OFF_RATING, ⁸​OFF_RATING, ⁹​E_DEF_RATING, ˟​DEF_RATING,
#   ˟​E_NET_RATING, ˟​NET_RATING
# ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names

$TeamStats
# A tibble: 2 × 29
  GAME_ID TEAM_ID TEAM_…¹ TEAM_…² TEAM_…³ MIN   E_OFF…⁴ OFF_R…⁵ E_DEF…⁶ DEF_R…⁷ E_NET…⁸ NET_R…⁹ AST_PCT AST_TOV AST_R…˟ OREB_…˟ DREB_…˟ REB_PCT E_TM_…˟
  <chr>   <chr>   <chr>   <chr>   <chr>   <chr> <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>  
1 104220… 161166… Storm   SEA     Seattle 200:… 92.6    94.8    102.5   102.6   -9.9    -7.8    0.643   2.57    18.2    0.171   0.78    0.476   8.879  
2 104220… 161166… Aces    LVA     Las Ve… 200:… 102.5   102.6   92.6    94.8    9.9     7.8     0.481   1.44    13.5    0.22    0.829   0.524   11.823 
# … with 10 more variables: TM_TOV_PCT <chr>, EFG_PCT <chr>, TS_PCT <chr>, USG_PCT <chr>, E_USG_PCT <chr>, E_PACE <chr>, PACE <chr>, PACE_PER40 <chr>,
#   POSS <chr>, PIE <chr>, and abbreviated variable names ¹​TEAM_NAME, ²​TEAM_ABBREVIATION, ³​TEAM_CITY, ⁴​E_OFF_RATING, ⁵​OFF_RATING, ⁶​E_DEF_RATING,
#   ⁷​DEF_RATING, ⁸​E_NET_RATING, ⁹​NET_RATING, ˟​AST_RATIO, ˟​OREB_PCT, ˟​DREB_PCT, ˟​E_TM_TOV_PCT
# ℹ Use `colnames()` to see all variable names