
Count the as-of-event goal, shots on goal, Fenwick, and Corsi attempts and differentials for all the events (plays) in a play-by-play by perspective
Source:R/Clean.R
count_goals_shots.Rdcount_goals_shots() counts the as-of-event goal, shots on goal, Fenwick,
and Corsi attempts and differentials for all the events (plays) in a
play-by-play by perspective.
Arguments
- play_by_play
data.frame of play-by-play(s); see
gc_play_by_play()and/orwsc_play_by_play()for reference; must be untouched by non-nhlscraper functions; saves time ifflag_is_home()has already been called
Value
data.frame with one row per event (play) and added columns:
homeGoals, awayGoals, homeSOG, awaySOG, homeFenwick,
awayFenwick, homeCorsi, awayCorsi, goalsFor, goalsAgainst,
SOGFor, SOGAgainst, fenwickFor, fenwickAgainst, corsiFor,
corsiAgainst, goalDifferential, SOGDifferential,
fenwickDifferential, and corsiDifferential
Examples
# May take >5s, so skip.
# \donttest{
test <- gc_play_by_play()
test_is_home_flagged <- flag_is_home(test)
test_goals_shots_counted <- count_goals_shots(test_is_home_flagged)
# }