sportsdataverse / hoopR

An R package to quickly obtain clean and tidy men's basketball play by play data.
http://hoopr.sportsdataverse.org/
Other
81 stars 17 forks source link

nba_schedule() issue with game_date field #120

Closed rossdrucker closed 10 months ago

rossdrucker commented 10 months ago

Describe the bug nba_schedule() does not always return a schedule due to parsing of game_date field with lubridate::ymd()

To Reproduce

library(hoopR)
nba_schedule(1984)
#> Request failed [500]. Retrying in 1.5 seconds...
#> Request failed [500]. Retrying in 1.1 seconds...
#> Error: The API returned an error
nba_schedule(1985)
#> # A tibble: 1,014 × 18
#>    game_id    season_t…¹ seaso…² visit…³ visit…⁴ visit…⁵ visit…⁶ visit…⁷ visit…⁸
#>    <chr>      <chr>      <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>  
#>  1 0028500004 2          Regula… 161061… Boston  Celtics Boston  BOS     Boston…
#>  2 0028500005 2          Regula… 161061… Washin… Bullets Washin… WAS     Washin…
#>  3 0028500006 2          Regula… 161061… Los An… Clippe… L.A. C… LAC     Los An…
#>  4 0028500007 2          Regula… 161061… Clevel… Cavali… Clevel… CLE     Clevel…
#>  5 0028500008 2          Regula… 161061… Denver  Nuggets Denver  DEN     Denver…
#>  6 0028500009 2          Regula… 161061… Phoenix Suns    Phoenix PHX     Phoeni…
#>  7 0028500010 2          Regula… 161061… Milwau… Bucks   Milwau… MIL     Milwau…
#>  8 0028500011 2          Regula… 161061… Houston Rockets Houston HOU     Housto…
#>  9 0028500012 2          Regula… 161061… Philad… 76ers   Philad… PHL     Philad…
#> 10 0028500013 2          Regula… 161061… Atlanta Hawks   Atlanta ATL     Atlant…
#> # … with 1,004 more rows, 9 more variables: home_team_id <chr>,
#> #   home_city <chr>, home_nickname <chr>, home_name_short <chr>,
#> #   home_abbr <chr>, home_team_name_full <chr>, game_date <date>,
#> #   game_start_time <chr>, day <chr>, and abbreviated variable names
#> #   ¹​season_type_id, ²​season_type_description, ³​visitor_team_id, ⁴​visitor_city,
#> #   ⁵​visitor_nickname, ⁶​visitor_name_short, ⁷​visitor_abbr,
#> #   ⁸​visitor_team_name_full

Created on 2023-08-24 by the reprex package (v2.0.1)

Expected behavior

> nba_schedule(1984)
# A tibble: 1,025 × 47
   game_date    game_id game_…¹ game_…² game_…³ game_…⁴ game_…⁵ game_…⁶ game_…⁷ game_…⁸ game_…⁹ game_…˟ away_…˟ home_…˟ day  
   <chr>        <chr>   <chr>     <int> <chr>     <int> <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>
#>  1 09/03/1984 … 001840… 198409…       1 7:00 p…       1 1984-0… 1900-0… 1984-0… 1984-0… 1900-0… 1984-0… 0001-0… 0001-0… Mon  
#>  2 09/03/1984 … 001840… 198409…       1 7:00 p…       2 1984-0… 1900-0… 1984-0… 1984-0… 1900-0… 1984-0… 0001-0… 0001-0… Mon  
#>  3 09/05/1984 … 001840… 198409…       1 7:00 p…       1 1984-0… 1900-0… 1984-0… 1984-0… 1900-0… 1984-0… 0001-0… 0001-0… Wed  
#>  4 09/05/1984 … 001840… 198409…       1 7:00 p…       2 1984-0… 1900-0… 1984-0… 1984-0… 1900-0… 1984-0… 0001-0… 0001-0… Wed  
#>  5 09/07/1984 … 001840… 198409…       1 7:00 p…       1 1984-0… 1900-0… 1984-0… 1984-0… 1900-0… 1984-0… 0001-0… 0001-0… Fri  
#>  6 09/07/1984 … 001840… 198409…       1 7:00 p…       2 1984-0… 1900-0… 1984-0… 1984-0… 1900-0… 1984-0… 0001-0… 0001-0… Fri  
#>  7 09/09/1984 … 001840… 198409…       1 7:00 p…       1 1984-0… 1900-0… 1984-0… 1984-0… 1900-0… 1984-0… 0001-0… 0001-0… Sun  
#>  8 09/09/1984 … 001840… 198409…       1 7:00 p…       2 1984-0… 1900-0… 1984-0… 1984-0… 1900-0… 1984-0… 0001-0… 0001-0… Sun  
#>  9 09/11/1984 … 001840… 198409…       1 7:00 p…       1 1984-0… 1900-0… 1984-0… 1984-0… 1900-0… 1984-0… 0001-0… 0001-0… Tue  
#> 10 09/11/1984 … 001840… 198409…       1 7:00 p…       2 1984-0… 1900-0… 1984-0… 1984-0… 1900-0… 1984-0… 0001-0… 0001-0… Tue  
# … with 1,015 more rows, 32 more variables: month_num <int>, week_number <int>, week_name <chr>, if_necessary <chr>,
#   series_game_number <chr>, series_text <chr>, arena_name <chr>, arena_state <chr>, arena_city <chr>,
#   postponed_status <chr>, branch_link <chr>, game_subtype <chr>, home_team_id <int>, home_team_name <chr>,
#   home_team_city <chr>, home_team_tricode <chr>, home_team_slug <chr>, home_team_wins <int>, home_team_losses <int>,
#   home_team_score <int>, home_team_seed <int>, away_team_id <int>, away_team_name <chr>, away_team_city <chr>,
#   away_team_tricode <chr>, away_team_slug <chr>, away_team_wins <int>, away_team_losses <int>, away_team_score <int>,
#   away_team_seed <int>, season <chr>, league_id <chr>, and abbreviated variable names ¹​game_code, ²​game_status, …
# ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names

Screenshots N/A

Desktop (please complete the following information):

Additional context N/A