Skip to contents

Get 4th down plays from a game.

Usage

get_4th_plays(df)

Arguments

df

A data frame of a game to get 4th down decisions of.

Value

Original data frame Data frame plus the following columns added:

desc

Play description from ESPN.

type_text

Play type text from ESPN.

index

Index number of play from a given game. Useful for tracking plays (e.g. for 4th down bot).

The rest

All the columns needed for `add_4th_probs().`

Details

Obtains a data frame that can be used with `add_4th_probs()`. The following columns must be present:

  • game_id : ESPN game ID from ESPN or cfbfastR (eg '401114223')

  • home_team : Name of the home team

  • away_team : Name of the away team

Examples

# \donttest{

game <- cfbfastR::cfbd_game_info(2019, team = "Utah", week = 3)
plays <- cfb4th::get_4th_plays(game)

dplyr::glimpse(plays)
#> Rows: 15
#> Columns: 42
#> $ game_id                          <int> 401114225, 401114225, 401114225, 4011…
#> $ play_id                          <chr> "401114225101878201", "40111422510187…
#> $ yr                               <dbl> 2021, 2021, 2021, 2021, 2021, 2021, 2…
#> $ desc                             <chr> "Jadon Redding 35 yd FG GOOD", "Kevin…
#> $ play_text                        <chr> "Jadon Redding 35 yd FG GOOD", "Kevin…
#> $ type                             <chr> "reg", "reg", "reg", "reg", "reg", "r…
#> $ qtr                              <int> 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3…
#> $ period                           <int> 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3…
#> $ half                             <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2…
#> $ TimeSecsRem                      <dbl> 1637, 1637, 1084, 926, 394, 77, 61, 5…
#> $ time                             <dbl> 737, 737, 184, 26, 394, 77, 61, 53, 9…
#> $ pos_team                         <chr> "Utah", "Idaho State", "Idaho State",…
#> $ def_pos_team                     <chr> "Idaho State", "Utah", "Utah", "Utah"…
#> $ abbreviation                     <chr> "UTAH", "IDST", "IDST", "IDST", "UTAH…
#> $ away                             <chr> "Idaho State", "Idaho State", "Idaho …
#> $ home                             <chr> "Utah", "Utah", "Utah", "Utah", "Utah…
#> $ yards_to_goal                    <int> 17, 63, 46, 73, 1, 74, 55, 74, 42, 68…
#> $ down                             <int> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4…
#> $ yardline                         <chr> "IDST 17", "IDST 37", "UTAH 46", "IDS…
#> $ distance                         <int> 2, 11, 10, 8, 1, 16, 3, 9, 10, 3, 3, …
#> $ pos_team_timeouts_rem_before     <dbl> 3, 3, 2, 2, 3, 0, 2, 0, 3, 3, 3, 3, 3…
#> $ def_pos_team_timeouts_rem_before <dbl> 3, 3, 3, 3, 1, 2, 0, 2, 3, 3, 3, 3, 3…
#> $ home_opening_kickoff             <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ score_differential               <int> 0, -3, -10, -17, 24, -24, 24, -24, -2…
#> $ pos_team_total                   <dbl> 13.0, 50.5, 50.5, 50.5, 13.0, 50.5, 1…
#> $ pos_team_spread                  <dbl> -37.5, 37.5, 37.5, 37.5, -37.5, 37.5,…
#> $ spread                           <dbl> -37.5, -37.5, -37.5, -37.5, -37.5, -3…
#> $ over_under                       <dbl> 63.5, 63.5, 63.5, 63.5, 63.5, 63.5, 6…
#> $ runoff                           <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
#> $ home_score                       <int> 0, 3, 10, 17, 24, 24, 24, 24, 24, 31,…
#> $ away_score                       <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
#> $ pos_team_score                   <int> 0, 0, 0, 0, 24, 0, 24, 0, 0, 0, 0, 31…
#> $ def_pos_team_score               <int> 0, 3, 10, 17, 0, 24, 0, 24, 24, 31, 3…
#> $ type_text                        <chr> "Field Goal Good", "Punt", "Punt", "P…
#> $ play_type                        <chr> "Field Goal Good", "Punt", "Punt", "P…
#> $ Under_two                        <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, TR…
#> $ adj_TimeSecsRem                  <dbl> 3437, 3437, 2884, 2726, 2194, 1877, 1…
#> $ log_ydstogo                      <dbl> 2.833213, 4.143135, 3.828641, 4.29045…
#> $ Goal_To_Go                       <lgl> FALSE, FALSE, FALSE, FALSE, TRUE, FAL…
#> $ pos_score_diff_start             <int> 0, -3, -10, -17, 24, -24, 24, -24, -2…
#> $ pos_team_receives_2H_kickoff     <dbl> 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0…
#> $ index                            <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12…
# }