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_schedule(
  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
idintegerId.
uidcharacterESPN UID string (universal identifier).
datecharacterDate in YYYY-MM-DD format.
attendanceintegerReported attendance.
time_validlogicalTime valid.
neutral_sitelogicalNeutral site.
conference_competitionlogicalConference competition.
recentlogicalRecent.
start_datecharacterStart date (YYYY-MM-DD).
notes_typecharacterNotes type.
notes_headlinecharacterNotes headline.
type_idintegerType identifier (numeric).
type_abbreviationcharacterType abbreviation.
venue_idintegerUnique venue identifier.
venue_full_namecharacterVenue full name.
venue_address_citycharacterVenue address city.
venue_capacityintegerVenue seating capacity.
venue_indoorlogicalTRUE if the venue is indoors.
status_clockintegerStatus clock.
status_display_clockcharacterStatus display clock.
status_periodintegerStatus period.
status_type_idintegerUnique identifier for status type.
status_type_namecharacterStatus type name.
status_type_statecharacterStatus type state.
status_type_completedlogicalStatus type completed.
status_type_descriptioncharacterStatus type description.
status_type_detailcharacterStatus type detail.
status_type_short_detailcharacterStatus type short detail.
format_regulation_periodsintegerFormat regulation periods.
home_idintegerUnique identifier for home.
home_uidcharacterHome team's uid.
home_locationcharacterHome team's location.
home_namecharacterHome name.
home_abbreviationcharacterHome team's abbreviation.
home_display_namecharacterHome display name.
home_short_display_namecharacterHome short display name.
home_colorcharacterColor code (hex) for home.
home_alternate_colorcharacterColor code (hex) for home alternate.
home_is_activelogicalHome team's is active.
home_venue_idintegerUnique identifier for home venue.
home_logocharacterHome team logo URL.
home_scoreintegerHome team score at the time of the play.
home_winnerlogicalHome team's winner.
away_idintegerUnique identifier for away.
away_uidcharacterAway team's uid.
away_locationcharacterAway team's location.
away_namecharacterAway name.
away_abbreviationcharacterAway team's abbreviation.
away_display_namecharacterAway display name.
away_short_display_namecharacterAway short display name.
away_colorcharacterColor code (hex) for away.
away_alternate_colorcharacterColor code (hex) for away alternate.
away_is_activelogicalAway team's is active.
away_venue_idintegerUnique identifier for away venue.
away_logocharacterAway team logo URL.
away_scoreintegerAway team score at the time of the play.
away_winnerlogicalAway team's winner.
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).
venue_address_statecharacterVenue address state / region.
status_type_alt_detailcharacterStatus type alt detail.
PBPlogical
team_boxlogicalTeam box.
player_boxlogicalPlayer box.
game_date_timePOSIXctGame start date/time (ISO 8601).
game_dateDateGame date (YYYY-MM-DD).

Examples

# \donttest{
load_nba_schedule(seasons = most_recent_nba_season())
#> ── ESPN NBA Schedule from hoopR data repository ───────────────── hoopR 3.1.0 ──
#>  Data updated: 2026-06-04 12:02:40 UTC
#> # A tibble: 1,332 × 77
#>         id uid   date  attendance time_valid neutral_site conference_competition
#>      <int> <chr> <chr>      <dbl> <lgl>      <lgl>        <lgl>                 
#>  1  4.02e8 s:40… 2026…          0 TRUE       FALSE        FALSE                 
#>  2  4.02e8 s:40… 2026…          0 TRUE       FALSE        FALSE                 
#>  3  4.02e8 s:40… 2026…          0 TRUE       FALSE        FALSE                 
#>  4  4.02e8 s:40… 2026…          0 TRUE       FALSE        FALSE                 
#>  5  4.02e8 s:40… 2026…          0 TRUE       FALSE        FALSE                 
#>  6  4.02e8 s:40… 2026…          0 TRUE       FALSE        FALSE                 
#>  7  4.02e8 s:40… 2026…      18835 TRUE       FALSE        FALSE                 
#>  8  4.02e8 s:40… 2026…      18203 TRUE       FALSE        FALSE                 
#>  9  4.02e8 s:40… 2026…      19066 TRUE       FALSE        FALSE                 
#> 10  4.02e8 s:40… 2026…      18203 TRUE       FALSE        FALSE                 
#> # ℹ 1,322 more rows
#> # ℹ 70 more variables: play_by_play_available <lgl>, recent <lgl>,
#> #   start_date <chr>, broadcast <chr>, highlights <chr>, notes_type <chr>,
#> #   notes_headline <chr>, broadcast_market <chr>, broadcast_name <chr>,
#> #   type_id <int>, type_abbreviation <chr>, venue_id <int>,
#> #   venue_full_name <chr>, venue_address_city <chr>, venue_indoor <lgl>,
#> #   status_clock <dbl>, status_display_clock <chr>, status_period <dbl>, …
# }