Skip to contents

Helper that loads multiple seasons of NHL shift-by-shift data from the sportsdataverse-data releases.

Usage

load_nhl_shifts(
  seasons = most_recent_nhl_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

Arguments

seasons

A vector of 4-digit years (the end year of the NHL season; e.g., 2026 for the 2025-26 season). Min: 2011.

...

Additional arguments passed to an underlying function.

dbConnection

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

tablename

The name of the data table within the database

Value

A data frame (fastRhockey_data) with one row per shift change and the following columns:

col_nametypesdescription
event_teamcharacterTeam associated with the shift change.
periodintegerPeriod number.
period_timecharacterElapsed time in the period (MM:SS).
period_secondsintegerElapsed seconds in the period.
game_secondsintegerElapsed seconds in the game.
num_onintegerNumber of players coming on.
players_oncharacterNames of players coming on.
ids_oncharacterPlayer ids coming on.
num_offintegerNumber of players going off.
players_offcharacterNames of players going off.
ids_offcharacterPlayer ids going off.
eventcharacterEvent description label.
event_typecharacterStandardized event type code.
game_seconds_remainingintegerSeconds remaining in regulation.

Examples

# \donttest{
  try(load_nhl_shifts(2026))
#> ─────────────────────────────────────────────────────────── fastRhockey 1.0.0 ──
#> # A tibble: 655,455 × 17
#>    event_team   period period_time period_seconds game_seconds num_on players_on
#>    <chr>         <int> <chr>                <int>        <int>  <int> <chr>     
#>  1 Chicago Bla…      1 00:00                    0            0      6 Connor Mu…
#>  2 Florida Pan…      1 00:00                    0            0      6 Brad Marc…
#>  3 Chicago Bla…      1 00:34                   34           34      4 Teuvo Ter…
#>  4 Florida Pan…      1 00:34                   34           34      5 Jeff Petr…
#>  5 Chicago Bla…      1 00:39                   39           39      1 Frank Naz…
#>  6 Chicago Bla…      1 00:57                   57           57      1 Matthew G…
#>  7 Florida Pan…      1 01:02                   62           62      2 Aaron Ekb…
#>  8 Florida Pan…      1 01:05                   65           65      1 Mackie Sa…
#>  9 Chicago Bla…      1 01:06                   66           66      1 Ryan Dona…
#> 10 Florida Pan…      1 01:06                   66           66      2 Evan Rodr…
#> # ℹ 655,445 more rows
#> # ℹ 10 more variables: ids_on <chr>, num_off <int>, players_off <chr>,
#> #   ids_off <chr>, event <chr>, event_type <chr>, game_seconds_remaining <int>,
#> #   game_id <int>, season <int>, game_date <chr>
# }