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_mbb_pbp(
  seasons = most_recent_mbb_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

Arguments

seasons

A vector of 4-digit years associated with given men's college basketball seasons. (Min: 2006)

...

Additional arguments passed to an underlying function that writes the season data into a database (used by update_mbb_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
idnumericId.
sequence_numbercharacterSequence number representing a shot-possession (V3 PBP).
type_idcharacterType identifier (numeric).
type_textcharacterDisplay text for the type field.
textcharacterText description of the play / record.
away_scoreintegerAway team score at the time of the play.
home_scoreintegerHome team score at the time of the play.
period_numberintegerNumeric period (1-4 for quarters; 5+ for OT).
period_display_valuecharacterPeriod display label (e.g. '1st Quarter', 'OT').
clock_display_valuecharacterGame clock display string (e.g. '8:32').
scoring_playlogicalTRUE if the play resulted in points scored.
score_valueintegerPoint value of the play (2 / 3 / 1).
team_idcharacterUnique team identifier.
participants_0_athlete_idcharacterV2 PBP participant 0 (primary) athlete ID.
wallclockcharacterWallclock.
shooting_playlogicalTRUE if the play was a shooting attempt.
participants_1_athlete_idcharacterV2 PBP participant 1 (secondary) athlete ID.
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).
away_team_idintegerUnique identifier for the away team.
away_team_namecharacterAway team name.
away_team_mascotcharacterAway team mascot.
away_team_abbrevcharacterAway team three-letter abbreviation.
away_team_name_altcharacterAlternate away team name.
home_team_idintegerUnique identifier for the home team.
home_team_namecharacterHome team name.
home_team_mascotcharacterHome team mascot.
home_team_abbrevcharacterHome team three-letter abbreviation.
home_team_name_altcharacterAlternate home team name.
home_team_spreadnumericHome team's point spread.
game_spreadnumericGame spread (signed; positive = home favored).
home_favoritelogicalTRUE if the home team is the betting favorite.
game_spread_availablelogicalTRUE if a point spread was available.
game_idintegerUnique game identifier.
qtrintegerQuarter (1-4) or OT period (5+).
timecharacterTime / clock value.
clock_minutescharacterClock minutes split out for convenience.
clock_secondscharacterClock seconds split out for convenience.
halfcharacterHalf of the game (1 or 2).
game_halfcharacterHalf of the game (1 or 2).
lag_qtrnumericQuarter lag (the previous-play's quarter).
lead_qtrnumericQuarter lead (the next-play's quarter).
lag_game_halfcharacterHalf lag (the previous-play's half).
lead_game_halfcharacterHalf lead (the next-play's half).
start_quarter_seconds_remainingintegerSeconds remaining in the period at the start of the play.
start_half_seconds_remainingintegerSeconds remaining in the half at the start of the play.
start_game_seconds_remainingintegerSeconds remaining in the game at the start of the play.
game_play_numberintegerSequential play number within the game.
end_quarter_seconds_remainingnumericSeconds remaining in the period at the end of the play.
end_half_seconds_remainingnumericSeconds remaining in the half at the end of the play.
end_game_seconds_remainingnumericSeconds remaining in the game at the end of the play.
periodintegerPeriod of the game (1-4 quarters; 5+ for OT).
coordinate_xintegerX coordinate on the court (half-court layout).
coordinate_yintegerY coordinate on the court (half-court layout).
media_idcharacterMedia identifier (video / image).

Examples

# \donttest{
load_mbb_pbp(seasons = most_recent_mbb_season())
#> ── ESPN MBB Play-by-Play from hoopR data repository ───────────── hoopR 3.1.0 ──
#>  Data updated: 2026-06-03 03:52:08 UTC
#> # A tibble: 2,915,731 × 57
#>    game_play_number      id sequence_number type_id type_text   text  away_score
#>               <int>   <dbl>           <int>   <int> <chr>       <chr>      <int>
#>  1                1 4.02e17       120416832     615 Jumpball    Star…          0
#>  2                2 4.02e17       120416833     615 Jumpball    Jump…          0
#>  3                3 4.02e17       120416834     615 Jumpball    Jump…          0
#>  4                4 4.02e17       120416835     558 JumpShot    Tarr…          0
#>  5                5 4.02e17       120416836     587 Defensive … Elli…          0
#>  6                6 4.02e17       120416837     572 LayUpShot   More…          0
#>  7                7 4.02e17       120416838     586 Offensive … Mich…          0
#>  8                8 4.02e17       120416839     558 JumpShot    Aday…          0
#>  9                9 4.02e17       120416920     587 Defensive … Tarr…          0
#> 10               10 4.02e17       120416921     558 JumpShot    Bray…          0
#> # ℹ 2,915,721 more rows
#> # ℹ 50 more variables: home_score <int>, period_number <int>,
#> #   period_display_value <chr>, clock_display_value <chr>, scoring_play <lgl>,
#> #   score_value <int>, wallclock <chr>, shooting_play <lgl>,
#> #   coordinate_x_raw <dbl>, coordinate_y_raw <dbl>, points_attempted <int>,
#> #   short_description <chr>, game_id <int>, season <int>, season_type <int>,
#> #   home_team_id <int>, home_team_name <chr>, home_team_mascot <chr>, …
# }