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_pbp(
  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

Examples

# \donttest{
load_nba_pbp(2021)
#> ───────────────────────────────────────────────────────────────── hoopR 1.7.0 ──
#> # A tibble: 569,719 × 55
#>    shooting_play sequence_number period_display_value period_number home_score
#>    <lgl>         <chr>           <chr>                        <int>      <int>
#>  1 FALSE         4               1st Quarter                      1          0
#>  2 FALSE         7               1st Quarter                      1          0
#>  3 TRUE          9               1st Quarter                      1          0
#>  4 FALSE         10              1st Quarter                      1          0
#>  5 FALSE         11              1st Quarter                      1          0
#>  6 TRUE          13              1st Quarter                      1          1
#>  7 TRUE          14              1st Quarter                      1          2
#>  8 TRUE          15              1st Quarter                      1          3
#>  9 TRUE          16              1st Quarter                      1          3
#> 10 TRUE          18              1st Quarter                      1          5
#> # … with 569,709 more rows, and 50 more variables: coordinate_x <int>,
#> #   coordinate_y <int>, scoring_play <lgl>, clock_display_value <chr>,
#> #   team_id <chr>, type_id <chr>, type_text <chr>, away_score <int>, id <dbl>,
#> #   text <chr>, score_value <int>, participants_0_athlete_id <chr>,
#> #   participants_1_athlete_id <chr>, participants_2_athlete_id <chr>,
#> #   season <int>, season_type <int>, away_team_id <int>, away_team_name <chr>,
#> #   away_team_mascot <chr>, away_team_abbrev <chr>, away_team_name_alt <chr>, …
# }