Load Packages

library(cfbfastR)
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.4.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(DT)
## Warning: package 'DT' was built under R version 4.4.3

Load Play-by-Play Data

pbp <- load_cfb_pbp(2025)

Grab Data From APP vs CLT

pbp_app_clt <- pbp %>% filter(pos_team == "App State", def_pos_team == "Charlotte")

Get First Down Play Types and Statistics

down1 <- pbp_app_clt %>% 
  filter(pos_team == "App State", (rush == 1 | pass == 1), down == 1) %>% 
  mutate(
    play_type = case_when(
      rush == 1 ~ "Rush",
      pass == 1 ~ "Pass"
    )
  ) %>% 
  group_by(play_type) %>% 
  summarize(
    plays = n(),
    mean_epa = mean(EPA, na.rm = TRUE),
    success_rate = mean(success, na.rm = TRUE),
    ypa = mean(yards_gained, na.rm = TRUE),
  ) %>% 
  arrange(-mean_epa) %>% 
  mutate(across(where(is.numeric), round, 3))
## Warning: There was 1 warning in `mutate()`.
## ℹ In argument: `across(where(is.numeric), round, 3)`.
## Caused by warning:
## ! The `...` argument of `across()` is deprecated as of dplyr 1.1.0.
## Supply arguments directly to `.fns` through an anonymous function instead.
## 
##   # Previously
##   across(a:b, mean, na.rm = TRUE)
## 
##   # Now
##   across(a:b, \(x) mean(x, na.rm = TRUE))
datatable(down1)