Skip to contents

Helper that loads multiple seasons of pre-scraped PWHL play-by-play data from the sportsdataverse-data releases either into memory or writes it into a database.

Usage

load_pwhl_pbp(
  seasons = most_recent_pwhl_season(),
  ...,
  dbConnection = NULL,
  tablename = NULL
)

Arguments

seasons

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

...

Additional arguments passed to an underlying function that writes the season data into a database (used by update_pwhl_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 data frame (fastRhockey_data) with the following columns:

col_nametypesdescription
game_idintegerUnique game identifier.
eventcharacterPlay-by-play event description.
team_idintegerTeam identifier for the event.
period_of_gamecharacterPeriod in which the event occurred.
time_of_periodcharacterGame clock time within the period.
player_idintegerPrimary player identifier.
player_name_firstcharacterPrimary player first name.
player_name_lastcharacterPrimary player last name.
player_positioncharacterPrimary player position.
player_two_idintegerSecond player identifier.
player_two_name_firstcharacterSecond player first name.
player_two_name_lastcharacterSecond player last name.
player_two_positioncharacterSecond player position.
x_coordnumericEvent x-coordinate on the ice.
y_coordnumericEvent y-coordinate on the ice.
home_winintegerFlag for whether the home team won.
player_team_idintegerTeam identifier of the primary player.
event_typecharacterCategorized event type.
shot_qualitycharacterShot quality descriptor.
goallogicalFlag for whether the event was a goal.
goalie_idintegerGoalie identifier on the play.
goalie_firstcharacterGoalie first name.
goalie_lastcharacterGoalie last name.
player_three_idintegerThird player identifier.
player_three_name_firstcharacterThird player first name.
player_three_name_lastcharacterThird player last name.
player_three_positioncharacterThird player position.
empty_netcharacterEmpty-net flag.
game_winnercharacterGame-winning-goal flag.
penalty_shotcharacterPenalty-shot flag.
insurancecharacterInsurance-goal flag.
power_playintegerPower-play flag.
short_handedcharacterShort-handed flag.
plus_player_one_idintegerOn-ice plus player one identifier.
plus_player_one_firstcharacterOn-ice plus player one first name.
plus_player_one_lastcharacterOn-ice plus player one last name.
plus_player_one_positioncharacterOn-ice plus player one position.
plus_player_two_idintegerOn-ice plus player two identifier.
plus_player_two_firstcharacterOn-ice plus player two first name.
plus_player_two_lastcharacterOn-ice plus player two last name.
plus_player_two_positioncharacterOn-ice plus player two position.
plus_player_three_idintegerOn-ice plus player three identifier.
plus_player_three_firstcharacterOn-ice plus player three first name.
plus_player_three_lastcharacterOn-ice plus player three last name.
plus_player_three_positioncharacterOn-ice plus player three position.
plus_player_four_idintegerOn-ice plus player four identifier.
plus_player_four_firstcharacterOn-ice plus player four first name.
plus_player_four_lastcharacterOn-ice plus player four last name.
plus_player_four_positioncharacterOn-ice plus player four position.
plus_player_five_idintegerOn-ice plus player five identifier.
plus_player_five_firstcharacterOn-ice plus player five first name.
plus_player_five_lastcharacterOn-ice plus player five last name.
plus_player_five_positioncharacterOn-ice plus player five position.
minus_player_one_idintegerOn-ice minus player one identifier.
minus_player_one_firstcharacterOn-ice minus player one first name.
minus_player_one_lastcharacterOn-ice minus player one last name.
minus_player_one_positioncharacterOn-ice minus player one position.
minus_player_two_idintegerOn-ice minus player two identifier.
minus_player_two_firstcharacterOn-ice minus player two first name.
minus_player_two_lastcharacterOn-ice minus player two last name.
minus_player_two_positioncharacterOn-ice minus player two position.
minus_player_three_idintegerOn-ice minus player three identifier.
minus_player_three_firstcharacterOn-ice minus player three first name.
minus_player_three_lastcharacterOn-ice minus player three last name.
minus_player_three_positioncharacterOn-ice minus player three position.
minus_player_four_idintegerOn-ice minus player four identifier.
minus_player_four_firstcharacterOn-ice minus player four first name.
minus_player_four_lastcharacterOn-ice minus player four last name.
minus_player_four_positioncharacterOn-ice minus player four position.
minus_player_five_idintegerOn-ice minus player five identifier.
minus_player_five_firstcharacterOn-ice minus player five first name.
minus_player_five_lastcharacterOn-ice minus player five last name.
minus_player_five_positioncharacterOn-ice minus player five position.
penalty_lengthcharacterPenalty length in minutes.
game_datecharacterGame date.
game_seasonintegerSeason (concluding year, YYYY).
game_season_idcharacterHockeyTech season identifier.
home_team_idintegerHome team identifier.
home_teamcharacterHome team name.
away_team_idintegerAway team identifier.
away_teamcharacterAway team name.
x_coord_originalintegerOriginal raw x-coordinate.
y_coord_originalintegerOriginal raw y-coordinate.
x_coord_neutralintegerNeutral-orientation x-coordinate.
y_coord_neutralintegerNeutral-orientation y-coordinate.
x_coord_fixednumericFixed-orientation x-coordinate.
y_coord_fixednumericFixed-orientation y-coordinate.
x_coord_rightnumericRight-orientation x-coordinate.
y_coord_rightnumericRight-orientation y-coordinate.
x_coord_verticalnumericVertical-orientation x-coordinate.
y_coord_verticalnumericVertical-orientation y-coordinate.
minute_startintegerMinute the event started.
second_startintegerSecond the event started.
clockcharacterGame clock string.
sec_from_startintegerSeconds elapsed from the start of the game.

Examples

# \donttest{
  try(load_pwhl_pbp(2024))
#> Warning: Failed to readRDS from <https://github.com/sportsdataverse/sportsdataverse-data/releases/download/pwhl_pbp/play_by_play_2024.rds>
#> ─────────────────────────────────────────────────────────── fastRhockey 1.0.0 ──
#> # A tibble: 0 × 0
# }