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_nametypes
idnumeric
sequence_numbercharacter
type_idcharacter
type_textcharacter
textcharacter
away_scoreinteger
home_scoreinteger
period_numberinteger
period_display_valuecharacter
clock_display_valuecharacter
scoring_playlogical
score_valueinteger
team_idcharacter
participants_0_athlete_idcharacter
wallclockcharacter
shooting_playlogical
participants_1_athlete_idcharacter
seasoninteger
season_typeinteger
away_team_idinteger
away_team_namecharacter
away_team_mascotcharacter
away_team_abbrevcharacter
away_team_name_altcharacter
home_team_idinteger
home_team_namecharacter
home_team_mascotcharacter
home_team_abbrevcharacter
home_team_name_altcharacter
home_team_spreadnumeric
game_spreadnumeric
home_favoritelogical
game_spread_availablelogical
game_idinteger
qtrinteger
timecharacter
clock_minutescharacter
clock_secondscharacter
halfcharacter
game_halfcharacter
lag_qtrnumeric
lead_qtrnumeric
lag_game_halfcharacter
lead_game_halfcharacter
start_quarter_seconds_remaininginteger
start_half_seconds_remaininginteger
start_game_seconds_remaininginteger
game_play_numberinteger
end_quarter_seconds_remainingnumeric
end_half_seconds_remainingnumeric
end_game_seconds_remainingnumeric
periodinteger
coordinate_xinteger
coordinate_yinteger
media_idcharacter

Examples

# \donttest{
load_mbb_pbp(seasons = most_recent_mbb_season())
#> ── ESPN MBB Play-by-Play from hoopR data repository ───────────── hoopR 2.1.0 ──
#>  Data updated: 2023-11-28 11:07:16 UTC
#> # A tibble: 407,751 × 56
#>    game_play_number      id sequence_number type_id type_text   text  away_score
#>               <int>   <dbl>           <int>   <int> <chr>       <chr>      <int>
#>  1                1 4.02e17       101807001     558 JumpShot    Tris…          0
#>  2                2 4.02e17       101807301     587 Defensive … Trey…          0
#>  3                3 4.02e17       101809001     558 JumpShot    Clar…          2
#>  4                4 4.02e17       101815301     574 DunkShot    Dono…          2
#>  5                5 4.02e17       101817501     558 JumpShot    Trey…          2
#>  6                6 4.02e17       101817701     587 Defensive … Tris…          2
#>  7                7 4.02e17       101818201     558 JumpShot    Dono…          2
#>  8                8 4.02e17       101819901     598 Lost Ball … Clar…          2
#>  9                9 4.02e17       101819902     607 Steal       Cam …          2
#> 10               10 4.02e17       101825301     572 LayUpShot   Alex…          2
#> # ℹ 407,741 more rows
#> # ℹ 49 more variables: home_score <int>, period_number <int>,
#> #   period_display_value <chr>, clock_display_value <chr>, scoring_play <lgl>,
#> #   score_value <int>, team_id <int>, athlete_id_1 <int>, wallclock <chr>,
#> #   shooting_play <lgl>, game_id <int>, season <int>, season_type <int>,
#> #   home_team_id <int>, home_team_name <chr>, home_team_mascot <chr>,
#> #   home_team_abbrev <chr>, home_team_name_alt <chr>, away_team_id <int>, …
# }