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)
#> ── ESPN NBA Play-by-Play Information from hoopR data repository ────────────────
#>  Data updated: 2022-10-21 21:14:04 UTC
#> # A tibble: 542,521 × 55
#>         id seque…¹ type_id type_…² text  away_…³ home_…⁴ perio…⁵ perio…⁶ clock…⁷
#>      <dbl> <chr>   <chr>   <chr>   <chr>   <int>   <int>   <int> <chr>   <chr>  
#>  1 4.01e 9 4       615     Jumpba… Jame…       0       0       1 1st Qu… 12:00  
#>  2 4.01e 9 7       90      Out of… DeAn…       0       0       1 1st Qu… 11:50  
#>  3 4.01e 9 8       44      Shooti… Kyri…       0       0       1 1st Qu… 11:38  
#>  4 4.01e10 10      98      Free T… Step…       1       0       1 1st Qu… 11:38  
#>  5 4.01e10 11      99      Free T… Step…       2       0       1 1st Qu… 11:38  
#>  6 4.01e10 12      131     Pullup… Kyri…       2       2       1 1st Qu… 11:22  
#>  7 4.01e10 13      151     Cuttin… Jame…       4       2       1 1st Qu… 11:11  
#>  8 4.01e10 16      131     Pullup… Kevi…       4       5       1 1st Qu… 10:49  
#>  9 4.01e10 18      92      Jump S… Andr…       4       5       1 1st Qu… 10:31  
#> 10 4.01e10 19      155     Defens… Joe …       4       5       1 1st Qu… 10:25  
#> # … with 542,511 more rows, 45 more variables: scoring_play <lgl>,
#> #   score_value <int>, team_id <chr>, participants_0_athlete_id <chr>,
#> #   participants_1_athlete_id <chr>, shooting_play <lgl>, coordinate_x <int>,
#> #   coordinate_y <int>, 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>, …
# }