calculate_series_conversion_rates: Compute Series Conversion Information from Play by Play

View source: R/calculate_series_conversion_rates.R

calculate_series_conversion_ratesR Documentation

Compute Series Conversion Information from Play by Play

Description

A "Series" begins on a 1st and 10 and each team attempts to either earn a new 1st down (on offense) or prevent the offense from converting a new 1st down (on defense). Series conversion rate represents how many series have been either converted to a new 1st down or ended in a touchdown. This function computes series conversion rates on offense and defense from nflverse play-by-play data along with other series results. The function automatically removes series that ended in a QB kneel down.

Usage

calculate_series_conversion_rates(pbp, weekly = FALSE)

Arguments

pbp

Play-by-play data as returned by load_pbp(), build_nflfastR_pbp(), or fast_scraper().

weekly

If TRUE, returns week-by-week stats, otherwise, season-by-season stats in argument pbp.

Value

A data frame of series information including the following columns:

season

The NFL season

team

NFL team abbreviation

week

Week if weekly is TRUE

off_n

The number of series the offense played (excludes QB kneel downs, kickoffs, extra point/two point conversion attempts, non-plays, and plays that do not list a "posteam")

off_scr

The rate at which a series ended in either new 1st down or touchdown while the offense was on the field

off_scr_1st

The rate at which an offense earned a 1st down or scored a touchdown on 1st down

off_scr_2nd

The rate at which an offense earned a 1st down or scored a touchdown on 2nd down

off_scr_3rd

The rate at which an offense earned a 1st down or scored a touchdown on 3rd down

off_scr_4th

The rate at which an offense earned a 1st down or scored a touchdown on 4th down

off_1st

The rate of series that ended in a new 1st down while the offense was on the field (does not include offensive touchdown)

off_td

The rate of series that ended in an offensive touchdown while the offense was on the field

off_fg

The rate of series that ended in a field goal attempt while the offense was on the field

off_punt

The rate of series that ended in a punt while the offense was on the field

off_to

The rate of series that ended in a turnover (including on downs), in an opponent score, or at the end of half (or game) while the offense was on the field

def_n

The number of series the defense played (excludes QB kneel downs, kickoffs, extra point/two point conversion attempts, non-plays, and plays that do not list a "posteam")

def_scr

The rate at which a series ended in either new 1st down or touchdown while the defense was on the field

def_scr_1st

The rate at which a defense allowed a 1st down or touchdown on 1st down

def_scr_2nd

The rate at which a defense allowed a 1st down or touchdown on 2nd down

def_scr_3rd

The rate at which a defense allowed a 1st down or touchdown on 3rd down

def_scr_4th

The rate at which a defense allowed a 1st down or touchdown on 4th down

def_1st

The rate of series that ended in a new 1st down while the defense was on the field (does not include offensive touchdown)

def_td

The rate of series that ended in an offensive touchdown while the defense was on the field

def_fg

The rate of series that ended in a field goal attempt while the defense was on the field

def_punt

The rate of series that ended in a punt while the defense was on the field

def_to

The rate of series that ended in a turnover (including on downs), in an opponent score, or at the end of half (or game) while the defense was on the field

Examples


try({# to avoid CRAN test problems
  pbp <- nflfastR::load_pbp(2021)

  weekly <- calculate_series_conversion_rates(pbp, weekly = TRUE)
  dplyr::glimpse(weekly)

  overall <- calculate_series_conversion_rates(pbp, weekly = FALSE)
  dplyr::glimpse(overall)
})


nflfastR documentation built on Oct. 20, 2023, 5:14 p.m.