Skip to contents

Helper that loads multiple seasons of NHL goal-scoring event data from the sportsdataverse-data releases.

Usage

load_nhl_scoring(
  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 goal and the following columns:

col_nametypesdescription
situationCodecharacterStrength/situation code for the goal.
eventIdintegerNHL event identifier.
strengthcharacterStrength state at which the goal was scored.
playerIdintegerPlayer id of the goal scorer.
firstNamelistScorer first name (localized list).
lastNamelistScorer last name (localized list).
namelistScorer display name (localized list).
teamAbbrevlistScoring team abbreviation (localized list).
headshotcharacterURL to the scorer headshot image.
highlightClipSharingUrlcharacterShareable URL for the goal highlight clip.
highlightClipnumericHighlight clip identifier.
discreteClipnumericDiscrete clip identifier.
goalsToDateintegerScorer goal total to date in the season.
awayScoreintegerAway team score after the goal.
homeScoreintegerHome team score after the goal.
leadingTeamAbbrevlistAbbreviation of the leading team (localized list).
timeInPeriodcharacterTime within the period the goal was scored.
shotTypecharacterType of shot on the goal.
goalModifiercharacterGoal modifier (e.g. empty-net, power-play).
assistslistList of assisting players on the goal.
pptReplayUrlcharacterURL to the power-play replay, if any.
homeTeamDefendingSidecharacterSide of the ice the home team defended.
isHomelogicalWhether the scoring team is the home team.
period_numberintegerPeriod number the goal was scored in.
period_typecharacterPeriod type (REG/OT/SO).

Examples

# \donttest{
  try(load_nhl_scoring(2026))
#> ─────────────────────────────────────────────────────────── fastRhockey 1.0.0 ──
#> # A tibble: 8,682 × 47
#>    situationCode eventId strength playerId headshot       highlightClipSharing…¹
#>    <chr>           <int> <chr>       <int> <chr>          <chr>                 
#>  1 1551              258 ev        8483493 https://asset… https://nhl.com/video…
#>  2 1551              274 ev        8478421 https://asset… https://nhl.com/video…
#>  3 1451              366 pp        8477409 https://asset… https://nhl.com/video…
#>  4 1551              630 ev        8476882 https://asset… https://nhl.com/video…
#>  5 1551             1101 ev        8480003 https://asset… https://nhl.com/video…
#>  6 1551              481 ev        8479638 https://asset… https://nhl.com/video…
#>  7 1560             1123 ev        8479638 https://asset… https://nhl.com/video…
#>  8 1560              112 ev        8481481 https://asset… https://nhl.com/video…
#>  9 1551              562 ev        8480039 https://asset… https://nhl.com/video…
#> 10 1551              647 ev        8484258 https://asset… https://nhl.com/video…
#> # ℹ 8,672 more rows
#> # ℹ abbreviated name: ¹​highlightClipSharingUrl
#> # ℹ 41 more variables: highlightClipSharingUrlFr <chr>, highlightClip <dbl>,
#> #   highlightClipFr <dbl>, discreteClip <dbl>, discreteClipFr <dbl>,
#> #   goalsToDate <int>, awayScore <int>, homeScore <int>, timeInPeriod <chr>,
#> #   shotType <chr>, goalModifier <chr>, assists <chr>, pptReplayUrl <chr>,
#> #   homeTeamDefendingSide <chr>, isHome <lgl>, game_id <int>, …
# }