This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(ggrepel) | |
| library(ggimage) | |
| library(ggtext) | |
| library(mgcv) | |
| library(scales) | |
| library(ggforce) | |
| library(nflfastR) | |
| library(na.tools) | |
| library(bayesboot) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(xgboost) | |
| library(magrittr) | |
| library(dplyr) | |
| library(Matrix) | |
| library(na.tools) | |
| library(ggimage) | |
| library(nflfastR) | |
| library(gt) | |
| library(mgcv) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(gganimate) | |
| library(mvtnorm) | |
| team_ <- "DET" | |
| qb_ <- "M.Stafford" | |
| min_offense_play_result <- 25 | |
| stafford_play <- df_plays %>% | |
| dplyr::filter(possessionTeam == team_, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | |
| ) %>% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(gganimate) | |
| library(cowplot) | |
| library(repr) | |
| library(grid) | |
| library(gridExtra) | |
| library(rpart) | |
| library(rpart.plot) | |
| library(caret) | |
| library(e1071) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(nflfastR) | |
| library(ggplot2) | |
| library(dplyr) | |
| library(hrbrthemes) | |
| library(ggrepel) | |
| library(ggimage) | |
| games <- readRDS(url("http://www.habitatring.com/games.rds")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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) |