Skip to contents

calculate_expected_goals() scores shot events with nhlscraper's built-in ridge expected-goals model. The runtime model is a fixed six-partition system: sd (5v5), ev (other even strength), pp (power play), sh (short-handed), en (empty net against), and so (shootout / penalty shot). The legacy model argument is accepted for backward compatibility but ignored.

Usage

calculate_expected_goals(play_by_play, model = NULL)

calculate_xG(play_by_play, model = NULL)

Arguments

play_by_play

data.frame of play-by-play(s) using the current public schema returned by gc_play_by_play(), gc_play_by_plays(), wsc_play_by_play(), or wsc_play_by_plays()

model

deprecated legacy model selector; ignored

Value

data.frame with one row per event (play) and added xG column

Examples

# May take >5s, so skip.
# \donttest{
  pbp <- gc_play_by_play()
  pbp_with_xg <- calculate_expected_goals(play_by_play = pbp)
# }