Assignment Descripton

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

new paragraph


<img = >

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



load_packages(c("data.table", "dplyr", "ggplot2", "stringr", "scales", "hms", "gganimate", "gifski", "ggforce", "sf"))


suppressMessages(library(data.table))

y1 <- fread("tracking2018.csv")
y2 <- fread("tracking2019.csv")
y3 <- fread("tracking2020.csv")
##3 These are data frames

tracking_df <- rbind(y1, y2, y3)
rm(y1, y2, y3)
plays <- fread("C:\\Users\\toria\\OneDrive\\Documents\\Rstudio\\nfl-big-data-bowl-2022\\plays.csv")

players <- fread("C:\\Users\\toria\\OneDrive\\Documents\\Rstudio\\nfl-big-data-bowl-2022\\players.csv")

games <- fread("C:\\Users\\toria\\OneDrive\\Documents\\Rstudio\\nfl-big-data-bowl-2022\\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

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)) 

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.