View source: R/ep_wp_calculators.R

calculate_expected_points | R Documentation |

for provided plays. Returns the data with probabilities of each scoring event and EP added. The following columns must be present: season, home_team, posteam, roof (coded as 'open', 'closed', or 'retractable'), half_seconds_remaining, yardline_100, ydstogo, posteam_timeouts_remaining, defteam_timeouts_remaining

calculate_expected_points(pbp_data)

`pbp_data` |
Play-by-play dataset to estimate expected points for. |

Computes expected points for provided plays. Returns the data with probabilities of each scoring event and EP added. The following columns must be present:

season

home_team

posteam

roof (coded as 'outdoors', 'dome', or 'open' / 'closed' / NA (retractable))

half_seconds_remaining

yardline_100

down

ydstogo

posteam_timeouts_remaining

defteam_timeouts_remaining

The original pbp_data with the following columns appended to it:

- ep
expected points.

- no_score_prob
probability of no more scoring this half.

- opp_fg_prob
probability next score opponent field goal this half.

- opp_safety_prob
probability next score opponent safety this half.

- opp_td_prob
probability of next score opponent touchdown this half.

- fg_prob
probability next score field goal this half.

- safety_prob
probability next score safety this half.

- td_prob
probability text score touchdown this half.

library(dplyr) data <- tibble::tibble( "season" = 1999:2019, "home_team" = "SEA", "posteam" = "SEA", "roof" = "outdoors", "half_seconds_remaining" = 1800, "yardline_100" = c(rep(80, 17), rep(75, 4)), "down" = 1, "ydstogo" = 10, "posteam_timeouts_remaining" = 3, "defteam_timeouts_remaining" = 3 ) nflfastR::calculate_expected_points(data) %>% dplyr::select(season, yardline_100, td_prob, ep)

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.