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

Not able to use the nba_boxscoresummaryv2() function #110

Closed TylerK00 closed 1 year ago

TylerK00 commented 1 year ago

When I attempt to use the nba_boxscoresummaryv2() function I get an error that says the object 'df_list' is not found. I've entered multiple games ids from each of the past two seasons and it's the same error for all of them. I am working on a capstone thesis and need the officials for each game, so help here would be much appreciated!

saiemgilani commented 1 year ago

Install the package from GitHub

remotes::install_github("sportsdataverse/hoopR")

Then try again, it is working on my end

TylerK00 commented 1 year ago

Thank you for your quick response. I installed the package and updated everything and still received the same error. I've attached a screenshot if that helps.

Screen Shot 2023-04-05 at 12 04 59 AM
saiemgilani commented 1 year ago

You're using ESPN game IDs for an NBA Stats API function. Find the appropriate corresponding NBA Stats API game_id from the nba_schedule() function.

TylerK00 commented 1 year ago

Am I still doing something wrong here?

Screen Shot 2023-04-05 at 2 58 44 PM
saiemgilani commented 1 year ago

That seems as though the code would technically work and for that specific game_id, I do actually find that it works on my end. However, that executed 15 straight games before giving you an error, which leads me to believe that you could just be getting rate limited. I would highly advise adding a Sys.sleep(3) in that loop. I would not expect to get more than 600 calls in an hour, so you do the math on that one. Just as a pro-tip: the third number is the season type, so I wouldn't worry about season type = 1 games, since that is the pre-season

> x <- nba_schedule(season=2022)
> View(x)
> nba_boxscoresummaryv2(game_id = '0012200016')
$GameSummary
# A tibble: 1 × 14
  GAME_DATE_EST       GAME_SEQUENCE GAME_ID    GAME_STATUS_ID GAME_STATUS_TEXT GAMECODE    HOME_TEAM_ID VISITOR_TEAM_ID SEASON LIVE_PERIOD
  <chr>               <chr>         <chr>      <chr>          <chr>            <chr>       <chr>        <chr>           <chr>  <chr>      
1 2022-10-04T00:00:00 3             0012200016 3              Final            20221004/N… 1610612741   1610612740      2022   4          
# ℹ 4 more variables: LIVE_PC_TIME <chr>, NATL_TV_BROADCASTER_ABBREVIATION <chr>, LIVE_PERIOD_TIME_BCAST <chr>, WH_STATUS <chr>

$OtherStats
# A tibble: 2 × 14
  LEAGUE_ID TEAM_ID    TEAM_ABBREVIATION TEAM_CITY   PTS_PAINT PTS_2ND_CHANCE PTS_FB LARGEST_LEAD LEAD_CHANGES TIMES_TIED TEAM_TURNOVERS
  <chr>     <chr>      <chr>             <chr>       <chr>     <chr>          <chr>  <chr>        <chr>        <chr>      <chr>         
1 00        1610612740 NOP               New Orleans 62        26             18     19           2            1          0             
2 00        1610612741 CHI               Chicago     50        23             25     4            2            1          1             
# ℹ 3 more variables: TOTAL_TURNOVERS <chr>, TEAM_REBOUNDS <chr>, PTS_OFF_TO <chr>

$Officials
# A tibble: 3 × 4
  OFFICIAL_ID FIRST_NAME LAST_NAME JERSEY_NUM
  <chr>       <chr>      <chr>     <chr>     
1 202007      Nick       Buchert   "3   "    
2 204059      Tyler      Ford      "39  "    
3 1627529     Suyash     Mehta     "82  "    

$InactivePlayers
# A tibble: 5 × 8
  PLAYER_ID FIRST_NAME LAST_NAME       JERSEY_NUM TEAM_ID    TEAM_CITY   TEAM_NAME TEAM_ABBREVIATION
  <chr>     <chr>      <chr>           <chr>      <chr>      <chr>       <chr>     <chr>            
1 1631241   Javon      Freeman-Liberty "00  "     1610612741 Chicago     Bulls     CHI              
2 1628366   Lonzo      Ball            "2   "     1610612741 Chicago     Bulls     CHI              
3 1630184   Kira       Lewis Jr.       "13  "     1610612740 New Orleans Pelicans  NOP              
4 1627742   Brandon    Ingram          "14  "     1610612740 New Orleans Pelicans  NOP              
5 1630530   Trey       Murphy III      "25  "     1610612740 New Orleans Pelicans  NOP              

$GameInfo
# A tibble: 1 × 3
  GAME_DATE                ATTENDANCE GAME_TIME
  <chr>                    <chr>      <chr>    
1 TUESDAY, OCTOBER 4, 2022 16322      2:34     

$LineScore
# A tibble: 2 × 23
  GAME_DATE_EST   GAME_SEQUENCE GAME_ID TEAM_ID TEAM_ABBREVIATION TEAM_CITY_NAME TEAM_NICKNAME TEAM_WINS_LOSSES PTS_QTR1 PTS_QTR2 PTS_QTR3
  <chr>           <chr>         <chr>   <chr>   <chr>             <chr>          <chr>         <chr>            <chr>    <chr>    <chr>   
1 2022-10-04T00:… 3             001220… 161061… CHI               Chicago        Bulls         0-1              25       28       39      
2 2022-10-04T00:… 3             001220… 161061… NOP               New Orleans    Pelicans      1-0              40       30       34      
# ℹ 12 more variables: PTS_QTR4 <chr>, PTS_OT1 <chr>, PTS_OT2 <chr>, PTS_OT3 <chr>, PTS_OT4 <chr>, PTS_OT5 <chr>, PTS_OT6 <chr>,
#   PTS_OT7 <chr>, PTS_OT8 <chr>, PTS_OT9 <chr>, PTS_OT10 <chr>, PTS <chr>

$LastMeeting
# A tibble: 0 × 0

$SeasonSeries
# A tibble: 1 × 7
  GAME_ID    HOME_TEAM_ID VISITOR_TEAM_ID GAME_DATE_EST       HOME_TEAM_WINS HOME_TEAM_LOSSES SERIES_LEADER
  <chr>      <chr>        <chr>           <chr>               <chr>          <chr>            <chr>        
1 0012200016 1610612741   1610612740      2022-10-04T00:00:00 0              1                New Orleans  

$AvailableVideo
# A tibble: 1 × 7
  GAME_ID    VIDEO_AVAILABLE_FLAG PT_AVAILABLE PT_XYZ_AVAILABLE WH_STATUS HUSTLE_STATUS HISTORICAL_STATUS
  <chr>      <chr>                <chr>        <chr>            <chr>     <chr>         <chr>            
1 0012200016 1                    0            0                1         1             0                
TylerK00 commented 1 year ago

That worked, thank you so much!

TylerK00 commented 1 year ago

My professor Brian Macdonald says hi too