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

Arguments

seasons

A vector of 4-digit years associated with given NHL seasons. (Min: 2011)

...

Additional arguments passed to an underlying function that writes the season data into a database (used by update_nhl_db()).

dbConnection

A DBIConnection object, as returned by DBI::dbConnect()

tablename

The name of the play by play data table within the database

Value

A dataframe

Examples

# \donttest{
  try(load_nhl_pbp(2021))
#> ── NHL Play-by-Play Information from fastRhockey data repository ───────────────
#>  Data updated: 2023-01-05 10:01:13 UTC
#> # A tibble: 593,081 × 105
#>    event_…¹ event descr…² period perio…³ perio…⁴ game_…⁵ game_…⁶ home_…⁷ away_…⁸
#>    <chr>    <chr> <chr>    <int>   <int>   <int>   <int>   <int>   <int>   <int>
#>  1 GAME_SC… Game… Game S…      1       0    1200       0    3600       0       0
#>  2 CHANGE   Chan… ON: Ju…      1       0    1200       0    3600       0       0
#>  3 CHANGE   Chan… ON: Si…      1       0    1200       0    3600       0       0
#>  4 FACEOFF  Face… Sidney…      1       0    1200       0    3600       0       0
#>  5 SHOT     Shot  Travis…      1      16    1184      16    3584       0       0
#>  6 TAKEAWAY Take… Takeaw…      1      23    1177      23    3577       0       0
#>  7 BLOCKED… Bloc… Sean C…      1      28    1172      28    3572       0       0
#>  8 SHOT     Shot  Evan R…      1      34    1166      34    3566       0       0
#>  9 CHANGE   Chan… ON: Cl…      1      34    1166      34    3566       0       0
#> 10 CHANGE   Chan… ON: Ev…      1      35    1165      35    3565       0       0
#> # … with 593,071 more rows, 95 more variables: strength_state <chr>,
#> #   event_idx <chr>, extra_attacker <lgl>, home_skaters <int>,
#> #   away_skaters <int>, game_id <int>, period_type <chr>, ordinal_num <chr>,
#> #   period_time <chr>, period_time_remaining <chr>, date_time <chr>,
#> #   home_final <int>, away_final <int>, season <int>, season_type <chr>,
#> #   game_date <chr>, game_start <chr>, game_end <chr>, game_length <int>,
#> #   game_state <chr>, detailed_state <chr>, venue_id <int>, venue_name <chr>, …
# }