Assignment Description

Paragraph explaining what this assignment is all about. next line next line

new paragraph


# Code goes in here
setwd("C:/Users/pptallon/Dropbox/G/Teaching/Loyola College/IS 470 Sports Analytics/Fall 2026/")

source("https://raw.githubusercontent.com/ptallon/SportsAnalytics_Fall2026/refs/heads/main/SharedCode.R")

library(data.table)
library(ggplot2)
library(dplyr)
 
y1 <- fread("NFLBDB2022/tracking2018.csv")
y2 <- fread("NFLBDB2022/tracking2019.csv")
y3 <- fread("NFLBDB2022/tracking2020.csv")

tracking_df <- rbind(y1, y2, y3)
rm(y1, y2, y3)
plays   <- fread("NFLBDB2022/plays.csv")
players <- fread("NFLBDB2022/players.csv")
games   <-  fread("NFLBDB2022/games.csv")

plays_df <- left_join(plays, players, by = c("kickerId" = "nflId"))
plays_df <- left_join(plays_df, games, by = c("gameId"))

df <- tracking_df |>
  filter(gameId == 2018123000, playId == 36) |>
  left_join(plays |> select(gameId, playId, 
                            absoluteYardlineNumber, playDescription),
            by = c("gameId", "playId")) |>
  data.frame()

More Blurb Heading

source("https://raw.githubusercontent.com/mlfurman3/gg_field/main/gg_field.R")
ggplot(df) +
  # Change the colors, shapes, and sizes of the points
  scale_size_manual(values = c(6, 4, 6), guide = "none") +
  scale_shape_manual(values = c(21, 16, 21), guide = "none") +
  scale_fill_manual(values = c("firebrick1", "black", "purple"), guide = "none") +
  scale_color_manual(values = c("black", "#663300", "black"), guide = "none" ) +
  
  # Visualize the field of play
  gg_field(yardmin = max(-5, min(df$x)-5), yardmax = min(125, max(df$x)+5)) +
  
  # Add points for each players and the ball
  geom_point(aes(x = x, y = y, shape = team, color = team, 
                 size = team, fill = team))