Learn R Programming

nhlscraper (version 0.4.2)

calculate_expected_goals_v3: Calculate version 3 of the expected goals for all the events (plays) in a play-by-play

Description

calculate_expected_goals_v3() calculates version 3 of the expected goals for all the events (plays) in a play-by-play using a pre-estimated logistic regression model of goal probability on distance, angle, empty net, strength state, rebound, rush, and goal differential.

Usage

calculate_expected_goals_v3(play_by_play)

calculate_xG_v3(play_by_play)

Value

data.frame with one row per event (play) and an added xG_v3

column containing expected goals for applicable shot attempts.

Arguments

play_by_play

data.frame of play-by-play(s); see gc_play_by_play() and/or wsc_play_by_play() for reference; must be untouched by non-nhlscraper functions; saves time if calculate_distance(), calculate_angle(), strip_situation_code(), flag_is_rebound(), flag_is_rush(), and/or count_goals_shots() have already been called

Examples

Run this code
# May take >5s, so skip.
# \donttest{
  test <- gc_play_by_play()
  test <- calculate_expected_goals_v3(test)
# }

Run the code above in your browser using DataLab