Skip to content

Instantly share code, notes, and snippets.

library(tidyverse)
library(xgboost)
library(magrittr)
library(dplyr)
library(Matrix)
library(na.tools)
library(ggimage)
library(nflfastR)
library(gt)
library(mgcv)
library(tidyverse)
library(nflfastR)
library(ggplot2)
library(dplyr)
library(hrbrthemes)
library(ggrepel)
library(ggimage)
games <- readRDS(url("http://www.habitatring.com/games.rds"))
pbp <- nflfastR::load_pbp(2020)
pbp_rp <- pbp %>%
filter(!is.na(epa)) %>%
filter(rush == 1 | pass == 1)
teams <- pbp_rp %>%
group_by(posteam, pass) %>%
summarize(epa = mean(epa))
library(tidyverse)
library(dplyr)
library(na.tools)
library(ggimage)
library(hrbrthemes)
library(viridis)
theme_tej <- function() {
theme(text = element_text(family='Tahoma', color="#232D4B"), # set font and color of all text
plot.title = element_text(size = 20, hjust = 0.5, face = "bold"),
library(tidyverse)
library(ggrepel)
library(ggimage)
library(ggtext)
library(mgcv)
library(scales)
library(ggforce)
library(nflfastR)
library(na.tools)
library(bayesboot)
library(tidyverse)
library(gganimate)
library(mvtnorm)
team_ <- "DET"
qb_ <- "M.Stafford"
min_offense_play_result <- 25
stafford_play <- df_plays %>%
dplyr::filter(possessionTeam == team_,
ridges <- df_plays_cov %>%
filter(epa > -2) %>%
filter(epa < 2)
ggplot(ridges, aes(x = epa, y = most_freq_cov, fill = most_freq_cov)) +
geom_density_ridges() +
theme_ridges() +
labs(x = "EPA Allowed",
y = "Coverage",
title = "EPA Ridge for Each Coverage",
caption = "By Tej Seth | @mfbanalytics | Data from the Big Data Bowl") +
cov_stats <- cov_stats %>%
mutate(freq = plays / 14575)
#Creating a table
cov_table <- cov_stats %>%
gt() %>%
tab_header(
title = "2018 Coverage Statistics",
subtitle = "Coverages were assigned based on random forest classification"
) %>%
library(tidyverse)
library(gganimate)
library(cowplot)
library(repr)
library(grid)
library(gridExtra)
library(rpart)
library(rpart.plot)
library(caret)
library(e1071)
#install.packages("tidyverse")
#install.packages("forcats")
#install.packages("hrbrthemes")
#install.packages("viridis")
#install.packages("ggrepel")
#Take out the '#' when installing the packages. I only included that in case you've already installed them.
#Tidyverse is the main one you need and the others are just for design.
library(tidyverse)