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_player_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_nametypes
game_idinteger
seasoninteger
season_typeinteger
game_dateDate
game_date_timePOSIXct
athlete_idinteger
athlete_display_namecharacter
team_idinteger
team_namecharacter
team_locationcharacter
team_short_display_namecharacter
minutesnumeric
field_goals_madeinteger
field_goals_attemptedinteger
three_point_field_goals_madeinteger
three_point_field_goals_attemptedinteger
free_throws_madeinteger
free_throws_attemptedinteger
offensive_reboundsinteger
defensive_reboundsinteger
reboundsinteger
assistsinteger
stealsinteger
blocksinteger
turnoversinteger
foulsinteger
plus_minuscharacter
pointsinteger
starterlogical
ejectedlogical
did_not_playlogical
reasoncharacter
activelogical
athlete_jerseycharacter
athlete_short_namecharacter
athlete_headshot_hrefcharacter
athlete_position_namecharacter
athlete_position_abbreviationcharacter
team_display_namecharacter
team_uidcharacter
team_slugcharacter
team_logocharacter
team_abbreviationcharacter
team_colorcharacter
team_alternate_colorcharacter
home_awaycharacter
team_winnerlogical
team_scoreinteger
opponent_team_idinteger
opponent_team_namecharacter
opponent_team_locationcharacter
opponent_team_display_namecharacter
opponent_team_abbreviationcharacter
opponent_team_logocharacter
opponent_team_colorcharacter
opponent_team_alternate_colorcharacter
opponent_team_scoreinteger

Examples

# \donttest{
  load_nba_player_box(seasons = most_recent_nba_season())
#> ── ESPN NBA Player Boxscores from hoopR data repository ───────── hoopR 2.1.1 ──
#>  Data updated: 2026-01-17 12:30:00 UTC
#> # A tibble: 16,117 × 57
#>      game_id season season_type game_date  game_date_time      athlete_id
#>        <int>  <int>       <int> <date>     <dttm>                   <int>
#>  1 401810447   2026           2 2026-01-16 2026-01-16 22:00:00    4432907
#>  2 401810447   2026           2 2026-01-16 2026-01-16 22:00:00    5174563
#>  3 401810447   2026           2 2026-01-16 2026-01-16 22:00:00    5160992
#>  4 401810447   2026           2 2026-01-16 2026-01-16 22:00:00    4845374
#>  5 401810447   2026           2 2026-01-16 2026-01-16 22:00:00    5238230
#>  6 401810447   2026           2 2026-01-16 2026-01-16 22:00:00    2581184
#>  7 401810447   2026           2 2026-01-16 2026-01-16 22:00:00    4277848
#>  8 401810447   2026           2 2026-01-16 2026-01-16 22:00:00    4565201
#>  9 401810447   2026           2 2026-01-16 2026-01-16 22:00:00    4606840
#> 10 401810447   2026           2 2026-01-16 2026-01-16 22:00:00    5144126
#> # ℹ 16,107 more rows
#> # ℹ 51 more variables: athlete_display_name <chr>, team_id <int>,
#> #   team_name <chr>, team_location <chr>, team_short_display_name <chr>,
#> #   minutes <dbl>, field_goals_made <int>, field_goals_attempted <int>,
#> #   three_point_field_goals_made <int>,
#> #   three_point_field_goals_attempted <int>, free_throws_made <int>,
#> #   free_throws_attempted <int>, offensive_rebounds <int>, …
# }