Skip to contents

helper that loads multiple seasons from the data repo either into memory or writes it into a db using some forwarded arguments in the dots

Usage

load_nba_team_box(
  seasons = most_recent_nba_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

Arguments

seasons

A vector of 4-digit years associated with given NBA seasons. (Min: 2002)

...

Additional arguments passed to an underlying function that writes the season data into a database (used by update_nba_db()).

dbConnection

A DBIConnection object, as returned by

tablename

The name of the play by play data table within the database

Value

Returns a tibble

col_nametypesdescription
game_idintegerUnique game identifier.
seasonintegerSeason identifier (4-digit year or 'YYYY-YY' string).
season_typeintegerSeason type (1=pre-season, 2=regular season, 3=postseason, 4=off-season for ESPN; or string label for WNBA Stats).
game_dateDateGame date (YYYY-MM-DD).
game_date_timePOSIXctGame start date/time (ISO 8601).
team_idintegerUnique team identifier.
team_uidcharacterESPN universal team identifier (UID format 's:40~l:...~t:...').
team_slugcharacterURL-safe team identifier (e.g. 'lasvegas-aces' / 'aces').
team_locationcharacterTeam city or location string.
team_namecharacterFull team display name (e.g. 'Las Vegas Aces').
team_abbreviationcharacterShort team abbreviation (e.g. 'LAS').
team_display_namecharacterFull team display name.
team_short_display_namecharacterShort team display name (e.g. 'Aces').
team_colorcharacterTeam primary color (hex without leading '#').
team_alternate_colorcharacterTeam alternate color (hex without leading '#').
team_logocharacterTeam logo image URL.
team_home_awaycharacterTeam home away.
team_scoreintegerTeam's score / final score.
team_winnerlogicalTRUE if the team won this game.
assistsintegerTotal assists.
blocksintegerTotal blocks.
defensive_reboundsintegerDefensive rebounds.
fast_break_pointscharacterFast-break points scored.
field_goal_pctnumericField goal percentage (0-1).
field_goals_madeintegerField goals made (2-pt + 3-pt).
field_goals_attemptedintegerField goal attempts (2-pt + 3-pt).
flagrant_foulsintegerTotal flagrant fouls.
foulsintegerPersonal fouls.
free_throw_pctnumericFree throw percentage (0-1).
free_throws_madeintegerFree throws made.
free_throws_attemptedintegerFree throw attempts.
largest_leadcharacterLargest lead during the game.
offensive_reboundsintegerOffensive rebounds.
points_in_paintcharacterPoints scored in the paint.
stealsintegerTotal steals.
team_turnoversintegerTeam turnovers (turnovers credited to the team rather than a player).
technical_foulsintegerTotal technical fouls.
three_point_field_goal_pctnumericThree-point field goal percentage (0-1).
three_point_field_goals_madeintegerThree-point field goals made.
three_point_field_goals_attemptedintegerThree-point field goal attempts.
total_reboundsintegerTotal rebounds.
total_technical_foulsintegerTotal technical fouls (player + team).
total_turnoversintegerTotal turnovers (player + team).
turnover_pointscharacterTurnover points.
turnoversintegerTotal turnovers.
opponent_team_idintegerUnique identifier for the opponent team.
opponent_team_uidcharacterOpponent team uid.
opponent_team_slugcharacterOpponent team slug.
opponent_team_locationcharacterOpponent team city / location.
opponent_team_namecharacterOpponent team display name.
opponent_team_abbreviationcharacterOpponent team abbreviation.
opponent_team_display_namecharacterOpponent team full display name.
opponent_team_short_display_namecharacterOpponent team short display name.
opponent_team_colorcharacterOpponent team primary color (hex).
opponent_team_alternate_colorcharacterOpponent team alternate color (hex).
opponent_team_logocharacterOpponent team logo URL.
opponent_team_scoreintegerOpponent team's score.

Examples

# \donttest{
load_nba_team_box(seasons = most_recent_nba_season())
#> ── ESPN NBA Team Boxscores from hoopR data repository ─────────── hoopR 3.1.0 ──
#>  Data updated: 2026-06-04 11:59:48 UTC
#> # A tibble: 2,644 × 59
#>      game_id season season_type game_date  game_date_time      team_id team_uid 
#>        <int>  <int>       <int> <date>     <dttm>                <int> <chr>    
#>  1 401859963   2026           3 2026-06-03 2026-06-03 20:30:00      18 s:40~l:4…
#>  2 401859963   2026           3 2026-06-03 2026-06-03 20:30:00      24 s:40~l:4…
#>  3 401873203   2026           3 2026-05-30 2026-05-30 20:00:00      24 s:40~l:4…
#>  4 401873203   2026           3 2026-05-30 2026-05-30 20:00:00      25 s:40~l:4…
#>  5 401873202   2026           3 2026-05-28 2026-05-28 20:30:00      25 s:40~l:4…
#>  6 401873202   2026           3 2026-05-28 2026-05-28 20:30:00      24 s:40~l:4…
#>  7 401873201   2026           3 2026-05-26 2026-05-26 20:30:00      24 s:40~l:4…
#>  8 401873201   2026           3 2026-05-26 2026-05-26 20:30:00      25 s:40~l:4…
#>  9 401873344   2026           3 2026-05-25 2026-05-25 20:00:00      18 s:40~l:4…
#> 10 401873344   2026           3 2026-05-25 2026-05-25 20:00:00       5 s:40~l:4…
#> # ℹ 2,634 more rows
#> # ℹ 52 more variables: team_slug <chr>, team_location <chr>, team_name <chr>,
#> #   team_abbreviation <chr>, team_display_name <chr>,
#> #   team_short_display_name <chr>, team_color <chr>,
#> #   team_alternate_color <chr>, team_logo <chr>, team_home_away <chr>,
#> #   team_score <int>, team_winner <lgl>, assists <int>, blocks <int>,
#> #   defensive_rebounds <int>, fast_break_points <chr>, field_goal_pct <dbl>, …
# }