Skip to contents

This function performs pre-processing steps to make expected points predictions on nflreadr data

Usage

ep_preprocess(pbp)

Arguments

pbp

pbp dataframe from nflreadr::load_pbp()

Value

a list of two dataframes (one for passes and one for rushes) of nflreadr data with the expectedpoints columns transformed for prediction

See also

vignette("basic") for example usage

Examples

# \donttest{
try({ # catch failures for CRAN purposes
  pbp_download <- readRDS(system.file("pbp_download.rds",package = "ffopportunity"))
  # this file is equivalent to nflreadr::load_pbp(2021) %>% head(1000)
  ep_preprocess(pbp_download)
  })
#> $rush_df
#> # A tibble: 252 × 43
#>    game_id play_id desc  rushe…¹ full_…² posteam two_p…³ two_p…⁴ rush_…⁵ first…⁶
#>    <chr>     <dbl> <chr> <chr>   <chr>   <chr>     <dbl>   <dbl>   <dbl>   <dbl>
#>  1 2021_0…      55 (15:… 00-003… Derric… TEN           0       0       1       0
#>  2 2021_0…     181 (12:… 00-003… Kyler … ARI           0       0       1       0
#>  3 2021_0…     282 (11:… 00-003… Chase … ARI           0       0       1       0
#>  4 2021_0…     473 (9:1… 00-003… Derric… TEN           0       0       1       0
#>  5 2021_0…     716 (8:1… 00-003… Derric… TEN           0       0       1       0
#>  6 2021_0…     737 (7:2… 00-003… Derric… TEN           0       0       1       0
#>  7 2021_0…     816 (6:4… 00-003… Chase … ARI           0       0       1       0
#>  8 2021_0…    1011 (2:2… 00-003… Derric… TEN           0       0       1       0
#>  9 2021_0…    1032 (1:4… 00-003… Derric… TEN           0       0       1       0
#> 10 2021_0…    1185 (14:… 00-003… James … ARI           0       0       1       0
#> # … with 242 more rows, 33 more variables: fumble_lost <dbl>, season <int>,
#> #   week <int>, rushing_yards <dbl>, rush_touchdown <fct>, first_down <fct>,
#> #   posteam_type <chr>, run_location <chr>, run_gap <chr>, run_gap_dir <chr>,
#> #   surface <chr>, wind <int>, temp <int>, roof <chr>, position <chr>,
#> #   yardline_100 <dbl>, half_seconds_remaining <dbl>,
#> #   game_seconds_remaining <dbl>, fixed_drive <dbl>, era <chr>, xpass <dbl>,
#> #   qtr <fct>, down <fct>, goal_to_go <fct>, ydstogo <dbl>, shotgun <fct>, …
#> 
#> $pass_df
#> # A tibble: 430 × 50
#>    game_id play_id desc  passe…¹ passe…² passe…³ recei…⁴ recei…⁵ recei…⁶ posteam
#>    <chr>     <dbl> <chr> <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>  
#>  1 2021_0…      76 (14:… 00-002… Ryan T… QB      00-003… Derric… RB      TEN    
#>  2 2021_0…     100 (13:… 00-002… Ryan T… QB      00-003… Cheste… WR      TEN    
#>  3 2021_0…     152 (13:… 00-003… Kyler … QB      00-003… DeAndr… WR      ARI    
#>  4 2021_0…     218 (12:… 00-003… Kyler … QB      00-003… Chase … RB      ARI    
#>  5 2021_0…     253 (11:… 00-003… Kyler … QB      00-002… A.J. G… WR      ARI    
#>  6 2021_0…     386 (10:… 00-003… Kyler … QB      00-003… Christ… WR      ARI    
#>  7 2021_0…     410 (9:2… 00-003… Kyler … QB      00-003… Rondal… WR      ARI    
#>  8 2021_0…     599 (8:3… 00-003… Kyler … QB      00-002… A.J. G… WR      ARI    
#>  9 2021_0…     621 (8:2… 00-003… Kyler … QB      00-003… Demetr… TE      ARI    
#> 10 2021_0…     660 (8:1… 00-003… Kyler … QB      00-003… DeAndr… WR      ARI    
#> # … with 420 more rows, 40 more variables: two_point_attempt <dbl>,
#> #   two_point_converted <dbl>, pass_attempt <dbl>, receiving_yards <dbl>,
#> #   first_down_pass <dbl>, fumble_lost <dbl>, season <int>, week <int>,
#> #   complete_pass <fct>, yards_after_catch <dbl>, pass_touchdown <fct>,
#> #   first_down <fct>, interception <fct>, relative_to_endzone <dbl>,
#> #   wind <int>, score_differential <dbl>, xpass <dbl>, vegas_wp <dbl>,
#> #   total_line <dbl>, implied_total <dbl>, relative_to_sticks <dbl>, …
#> 
# }