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.8.1 ──
#> # A tibble: 569,719 × 55
#>    shooting_play seque…¹ perio…² perio…³ home_…⁴ coord…⁵ coord…⁶ scori…⁷ clock…⁸
#>    <lgl>         <chr>   <chr>     <int>   <int>   <int>   <int> <lgl>   <chr>  
#>  1 FALSE         4       1st Qu…       1       0 -2.15e8 -2.15e8 FALSE   12:00  
#>  2 FALSE         7       1st Qu…       1       0  3.2 e1  3   e0 FALSE   11:46  
#>  3 TRUE          9       1st Qu…       1       0  2   e0 -2   e0 FALSE   11:27  
#>  4 FALSE         10      1st Qu…       1       0  2   e0 -2   e0 FALSE   11:23  
#>  5 FALSE         11      1st Qu…       1       0  4.3 e1  1.6 e1 FALSE   11:21  
#>  6 TRUE          13      1st Qu…       1       1 -2.15e8 -2.15e8 TRUE    11:21  
#>  7 TRUE          14      1st Qu…       1       2 -2.15e8 -2.15e8 TRUE    11:21  
#>  8 TRUE          15      1st Qu…       1       3 -2.15e8 -2.15e8 TRUE    11:21  
#>  9 TRUE          16      1st Qu…       1       3  3   e1  2.5 e1 TRUE    11:05  
#> 10 TRUE          18      1st Qu…       1       5  1.5 e1  1   e1 TRUE    10:42  
#> # … with 569,709 more rows, 46 more variables: 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>, home_team_id <int>,
#> #   home_team_name <chr>, home_team_mascot <chr>, home_team_abbrev <chr>, …
# }