Learn R Programming

nhlscraper (version 0.4.2)

add_on_ice_players: Add on-ice player IDs to a play-by-play by merging with shift charts

Description

add_on_ice_players() merges a play-by-play with a shift chart to determine which players are on the ice at each event. It adds home- and away-team on-ice player ID lists, as well as event-perspective for/against player ID lists when isHome is available.

Usage

add_on_ice_players(play_by_play, shift_chart)

Value

data.frame with one row per event (play) and added list-columns: homePlayerIds, awayPlayerIds, playerIdsFor, and playerIdsAgainst

Arguments

play_by_play

data.frame of shift chart rows; see gc_play_by_play(), gc_play_by_plays(), wsc_play_by_play(), or wsc_play_by_plays() for reference; the original columns must exist

shift_chart

data.frame of shift chart rows; see shift_chart() or shift_charts() for reference; the original columns must exist

Examples

Run this code
# May take >5s, so skip.
gc_pbp_enhanced <- add_on_ice_players(gc_pbp(), shift_chart())

Run the code above in your browser using DataLab