source('https://raw.githubusercontent.com/ptallon/SportsAnalytics_Fall2024/main/SharedCode.R')
setwd("/Users/jose/Desktop/Data Viz")
my_path <- paste0(getwd(), "/nfl2025/NFLBDB2025")
load_packages(c("data.table", "dplyr", "ggplot2", "ggalt", "gifski", "gganimate", "httr", "r02pro", "tidyverse"))

# first week data frame
df <- load_data_for_one_week(directory = my_path, week = 1, merge = TRUE)

# to check available files
list.files(path = my_path)
##  [1] "games.csv"           "player_play.csv"     "players.csv"        
##  [4] "plays.csv"           "tracking_week_1.csv" "tracking_week_2.csv"
##  [7] "tracking_week_3.csv" "tracking_week_4.csv" "tracking_week_5.csv"
## [10] "tracking_week_6.csv" "tracking_week_7.csv" "tracking_week_8.csv"
## [13] "tracking_week_9.csv"
# bring in games, plays, player_play if needed
games <- fread       (paste0(my_path, "/games.csv"))
plays <- fread       (paste0(my_path, "/plays.csv"))
player_play <- fread (paste0(my_path, "/player_play.csv"))

# initial data frame with just those in movement 
df %>%
  filter(inMotionAtBallSnap == TRUE) %>%
  select(displayName, jerseyNumber, playId, gameId) %>%
  distinct() %>%
  head() %>%
  data.frame() %>% print()
##     displayName jerseyNumber playId     gameId
## 1     Noah Fant           87     64 2022091200
## 2 Rashaad Penny           20     85 2022091200
## 3   Andrew Beck           83    264 2022091200
## 4   Andrew Beck           83    286 2022091200
## 5   Jerry Jeudy           10    401 2022091200
## 6   K.J. Hamler            1    446 2022091200
# update to initial data frame with just those in movement and frame type is before snap
temp_df <- df %>%
  filter(inMotionAtBallSnap == TRUE, frameType == "BEFORE_SNAP") %>%
  select(displayName, jerseyNumber, playId, gameId, frameId, x, y) %>%
  distinct() %>%
  head() %>%
  data.frame() %>% print()
##   displayName jerseyNumber playId     gameId frameId     x        y
## 1   Noah Fant           87     64 2022091200       1 86.59 27.71333
## 2   Noah Fant           87     64 2022091200       2 86.52 27.59333
## 3   Noah Fant           87     64 2022091200       3 86.45 27.49333
## 4   Noah Fant           87     64 2022091200       4 86.36 27.37333
## 5   Noah Fant           87     64 2022091200       5 86.26 27.26333
## 6   Noah Fant           87     64 2022091200       6 86.15 27.14333
# New update to single out single play with new normalized x and y values
secondtemp_df <- df %>%
  filter(inMotionAtBallSnap == TRUE, playId == 62, gameId == 2022091112, frameType == "BEFORE_SNAP") %>%
  select(displayName, jerseyNumber, playId, gameId, frameId, x, y) %>%
  group_by(displayName) %>%
  mutate( x = x - first(x[frameId == 1]),
          y = y - first(y[frameId == 1])) %>%
  distinct() %>%
  head() %>%
  data.frame() %>% print()
##    displayName jerseyNumber playId     gameId frameId     x     y
## 1 Adam Thielen           19     62 2022091112       1  0.00  0.00
## 2 Adam Thielen           19     62 2022091112       2  0.03 -0.25
## 3 Adam Thielen           19     62 2022091112       3  0.05 -0.52
## 4 Adam Thielen           19     62 2022091112       4  0.05 -0.82
## 5 Adam Thielen           19     62 2022091112       5  0.03 -1.11
## 6 Adam Thielen           19     62 2022091112       6 -0.01 -1.41

Funtions and Plots

#from original data frame, create a data frame and display just special columns in a specific game
process_play_data <- function(df, play_id, game_id) {
  df %>%
    filter(inMotionAtBallSnap == "TRUE", playId == play_id, gameId == game_id, frameType == "BEFORE_SNAP") %>%
    select(nflId, playId, gameId, frameId, x, y) %>%
    group_by(nflId) %>%
    distinct() %>%
    data.frame() %>%
    print()
}
# display a single motion play from a single play in dots
plot_grid_overlay <- function(data) {
    ggplot(data, aes(x = y, y = -x)) +

    # Add points for each (x, y) coordinate
    geom_point(aes(color = as.factor(nflId)), size = 4) +

    # Add labels using 'frameId'
    geom_text(aes(label = frameId), size = 3, vjust = -1, color = "black") +

    # Title and axis labels
    labs(title = "Grid Overlay with Dark Center Lines at X=0 and Y=0",
          x = "X Coordinate",
          y = "Y Coordinate") +
    
    # Minimal theme and custom grid lines
    theme_minimal() +
    theme(
    panel.grid.major = element_line(color = "black", size = 0.5), # Major grid lines
    panel.grid.minor = element_line(color = "gray", size = 0.25) # Minor grid lines
    )
}
#function that represents the process of x - the first x from first frame in a mutate
# Includes data from all games and all plays with the added column 
process_play_data_clust <- function(df) {
  df %>%
    filter(inMotionAtBallSnap == TRUE, frameType == "BEFORE_SNAP") %>%
    select(nflId, playId, gameId, frameId, x, y) %>%
    group_by(nflId) %>%
    mutate( x = x - first(x[frameId == 1]),
            y = y - first(y[frameId == 1])) %>%
    distinct() %>%
    data.frame() %>% print()
}
#initial attempt of mutate with rounding x and y
t_df <- df %>%
  filter(inMotionAtBallSnap == TRUE, frameType == "BEFORE_SNAP") %>%
  select(nflId, playId, gameId, frameId, x, y) %>%
  group_by(nflId) %>%
  mutate( x = round(x - first(x[frameId == 1])),
          y = round(y - first(y[frameId == 1]))) %>%
  distinct() %>%
  data.frame()

#second attempt of mutate without rounding x and y
t2_df <- df %>%
  filter(inMotionAtBallSnap == TRUE, frameType == "BEFORE_SNAP") %>%
  select(nflId, playId, gameId, frameId, x, y) %>%
  group_by(nflId) %>%
  mutate( x = (x - first(x[frameId == 1])),
          y = (y - first(y[frameId == 1]))) %>%
  distinct() %>%
  data.frame()
#---------kmeans-----------
# Example dataset
data <- t2_df
# Perform k-means clustering
set.seed(123) # For reproducibility
kmeans_result <- kmeans(data, centers = 3, iter.max = 20, nstart = 10)

# Add cluster assignments to the original dataset
data_with_clusters <- cbind(data, Cluster = kmeans_result$cluster)
# View the first few rows
head(data_with_clusters)
##   nflId playId     gameId frameId     x     y Cluster
## 1 47803     64 2022091200       1  0.00  0.00       3
## 2 47803     64 2022091200       2 -0.07 -0.12       3
## 3 47803     64 2022091200       3 -0.14 -0.22       3
## 4 47803     64 2022091200       4 -0.23 -0.34       3
## 5 47803     64 2022091200       5 -0.33 -0.45       3
## 6 47803     64 2022091200       6 -0.44 -0.57       3
# 2D visualization of clusters
ggplot(data_with_clusters, aes(x = playId, y = Cluster, color = as.factor(Cluster))) +
geom_point(size = 3) +
labs(color = "Cluster") +
theme_minimal()

wss <- sapply(1:10, function(k) {
kmeans(data, centers = k, nstart = 10)$tot.withinss
})

# Plot the Elbow Method
plot(1:10, wss, type = "b", pch = 19, frame = FALSE,
xlab = "Number of clusters (k)",
ylab = "Total within-cluster sum of squares",
main = "Elbow Method for Optimal k")

# from a sample of the different cluster we displayed from playId and gameId the dataframe and the visual grid
data_with_clusters %>% filter(Cluster == 3) %>% head() %>% print()
##   nflId playId     gameId frameId     x     y Cluster
## 1 47803     64 2022091200       1  0.00  0.00       3
## 2 47803     64 2022091200       2 -0.07 -0.12       3
## 3 47803     64 2022091200       3 -0.14 -0.22       3
## 4 47803     64 2022091200       4 -0.23 -0.34       3
## 5 47803     64 2022091200       5 -0.33 -0.45       3
## 6 47803     64 2022091200       6 -0.44 -0.57       3
data_with_clusters %>% filter(Cluster == 2) %>% head() %>% print()
##   nflId playId     gameId frameId    x     y Cluster
## 1 52423    401 2022091200       1 0.00  0.00       2
## 2 52423    401 2022091200       2 0.03 -0.26       2
## 3 52423    401 2022091200       3 0.05 -0.53       2
## 4 52423    401 2022091200       4 0.06 -0.83       2
## 5 52423    401 2022091200       5 0.07 -1.14       2
## 6 52423    401 2022091200       6 0.07 -1.46       2
data_with_clusters %>% filter(Cluster == 1) %>% head() %>% print()
##   nflId playId     gameId frameId    x    y Cluster
## 1 42358    931 2022091200       1 0.00 0.00       1
## 2 42358    931 2022091200       2 0.02 0.03       1
## 3 42358    931 2022091200       3 0.05 0.07       1
## 4 42358    931 2022091200       4 0.09 0.13       1
## 5 42358    931 2022091200       5 0.13 0.20       1
## 6 42358    931 2022091200       6 0.16 0.29       1
cluster1_df <- process_play_data(df, 931, 2022091200)
##     nflId playId     gameId frameId     x        y
## 1   42358    931 2022091200       1 70.98 22.84333
## 2   42358    931 2022091200       2 71.00 22.87333
## 3   42358    931 2022091200       3 71.03 22.91333
## 4   42358    931 2022091200       4 71.07 22.97333
## 5   42358    931 2022091200       5 71.11 23.04333
## 6   42358    931 2022091200       6 71.14 23.13333
## 7   42358    931 2022091200       7 71.17 23.22333
## 8   42358    931 2022091200       8 71.20 23.32333
## 9   42358    931 2022091200       9 71.22 23.43333
## 10  42358    931 2022091200      10 71.23 23.54333
## 11  42358    931 2022091200      11 71.24 23.66333
## 12  42358    931 2022091200      12 71.24 23.78333
## 13  42358    931 2022091200      13 71.23 23.90333
## 14  42358    931 2022091200      14 71.22 24.03333
## 15  42358    931 2022091200      15 71.21 24.15333
## 16  42358    931 2022091200      16 71.19 24.27333
## 17  42358    931 2022091200      17 71.16 24.38333
## 18  42358    931 2022091200      18 71.14 24.48333
## 19  42358    931 2022091200      19 71.11 24.57333
## 20  42358    931 2022091200      20 71.08 24.65333
## 21  42358    931 2022091200      21 71.04 24.72333
## 22  42358    931 2022091200      22 71.01 24.78333
## 23  42358    931 2022091200      23 70.98 24.83333
## 24  42358    931 2022091200      24 70.96 24.88333
## 25  42358    931 2022091200      25 70.93 24.92333
## 26  42358    931 2022091200      26 70.92 24.95333
## 27  42358    931 2022091200      27 70.90 24.98333
## 28  42358    931 2022091200      28 70.89 25.01333
## 29  42358    931 2022091200      29 70.88 25.03333
## 30  42358    931 2022091200      30 70.87 25.06333
## 31  42358    931 2022091200      31 70.87 25.08333
## 32  42358    931 2022091200      32 70.87 25.10333
## 33  42358    931 2022091200      33 70.87 25.11333
## 34  42358    931 2022091200      34 70.88 25.12333
## 35  42358    931 2022091200      35 70.88 25.12333
## 36  42358    931 2022091200      36 70.88 25.12333
## 37  42358    931 2022091200      37 70.88 25.12333
## 38  42358    931 2022091200      38 70.88 25.09333
## 39  42358    931 2022091200      39 70.88 25.05333
## 40  42358    931 2022091200      40 70.88 24.96333
## 41  42358    931 2022091200      41 70.88 24.86333
## 42  42358    931 2022091200      42 70.88 24.73333
## 43  42358    931 2022091200      43 70.89 24.58333
## 44  42358    931 2022091200      44 70.89 24.41333
## 45  42358    931 2022091200      45 70.89 24.23333
## 46  42358    931 2022091200      46 70.90 24.02333
## 47  42358    931 2022091200      47 70.90 23.81333
## 48  42358    931 2022091200      48 70.89 23.59333
## 49  42358    931 2022091200      49 70.87 23.37333
## 50  42358    931 2022091200      50 70.86 23.15333
## 51  42358    931 2022091200      51 70.84 22.94333
## 52  42358    931 2022091200      52 70.81 22.74333
## 53  42358    931 2022091200      53 70.78 22.54333
## 54  42358    931 2022091200      54 70.75 22.36333
## 55  42358    931 2022091200      55 70.71 22.19333
## 56  42358    931 2022091200      56 70.68 22.03333
## 57  42358    931 2022091200      57 70.65 21.90333
## 58  42358    931 2022091200      58 70.61 21.78333
## 59  42358    931 2022091200      59 70.58 21.68333
## 60  42358    931 2022091200      60 70.55 21.60333
## 61  42358    931 2022091200      61 70.52 21.53333
## 62  42358    931 2022091200      62 70.50 21.48333
## 63  42358    931 2022091200      63 70.48 21.45333
## 64  42358    931 2022091200      64 70.46 21.42333
## 65  42358    931 2022091200      65 70.45 21.41333
## 66  42358    931 2022091200      66 70.45 21.40333
## 67  42358    931 2022091200      67 70.45 21.40333
## 68  42358    931 2022091200      68 70.45 21.40333
## 69  42358    931 2022091200      69 70.45 21.41333
## 70  42358    931 2022091200      70 70.45 21.41333
## 71  42358    931 2022091200      71 70.45 21.42333
## 72  42358    931 2022091200      72 70.45 21.43333
## 73  42358    931 2022091200      73 70.46 21.44333
## 74  42358    931 2022091200      74 70.46 21.44333
## 75  42358    931 2022091200      75 70.46 21.45333
## 76  42358    931 2022091200      76 70.46 21.46333
## 77  42358    931 2022091200      77 70.47 21.46333
## 78  42358    931 2022091200      78 70.47 21.46333
## 79  42358    931 2022091200      79 70.47 21.47333
## 80  42358    931 2022091200      80 70.46 21.48333
## 81  42358    931 2022091200      81 70.45 21.49333
## 82  42358    931 2022091200      82 70.44 21.50333
## 83  42358    931 2022091200      83 70.43 21.50333
## 84  42358    931 2022091200      84 70.42 21.50333
## 85  42358    931 2022091200      85 70.41 21.50333
## 86  42358    931 2022091200      86 70.40 21.50333
## 87  42358    931 2022091200      87 70.40 21.50333
## 88  42358    931 2022091200      88 70.40 21.50333
## 89  42358    931 2022091200      89 70.41 21.50333
## 90  42358    931 2022091200      90 70.41 21.49333
## 91  42358    931 2022091200      91 70.41 21.49333
## 92  42358    931 2022091200      92 70.42 21.48333
## 93  42358    931 2022091200      93 70.42 21.48333
## 94  42358    931 2022091200      94 70.42 21.47333
## 95  42358    931 2022091200      95 70.41 21.47333
## 96  42358    931 2022091200      96 70.41 21.46333
## 97  42358    931 2022091200      97 70.40 21.46333
## 98  42358    931 2022091200      98 70.38 21.46333
## 99  42358    931 2022091200      99 70.37 21.46333
## 100 42358    931 2022091200     100 70.37 21.46333
## 101 42358    931 2022091200     101 70.36 21.47333
## 102 42358    931 2022091200     102 70.36 21.48333
## 103 42358    931 2022091200     103 70.34 21.49333
## 104 42358    931 2022091200     104 70.33 21.50333
## 105 42358    931 2022091200     105 70.31 21.52333
## 106 42358    931 2022091200     106 70.28 21.56333
## 107 42358    931 2022091200     107 70.23 21.60333
## 108 42358    931 2022091200     108 70.15 21.66333
## 109 42358    931 2022091200     109 70.05 21.74333
## 110 42358    931 2022091200     110 69.93 21.84333
## 111 42358    931 2022091200     111 69.78 21.96333
## 112 42358    931 2022091200     112 69.62 22.10333
## 113 42358    931 2022091200     113 69.44 22.27333
## 114 42358    931 2022091200     114 69.26 22.45333
## 115 42358    931 2022091200     115 69.07 22.67333
## 116 42358    931 2022091200     116 68.89 22.91333
## 117 42358    931 2022091200     117 68.73 23.17333
## 118 42358    931 2022091200     118 68.58 23.46333
## 119 42358    931 2022091200     119 68.44 23.77333
## 120 42358    931 2022091200     120 68.33 24.10333
## 121 42358    931 2022091200     121 68.24 24.44333
## 122 42358    931 2022091200     122 68.16 24.79333
## 123 42358    931 2022091200     123 68.09 25.14333
## 124 42358    931 2022091200     124 68.04 25.50333
## 125 42358    931 2022091200     125 68.00 25.85333
## 126 42358    931 2022091200     126 67.96 26.20333
## 127 42358    931 2022091200     127 67.93 26.55333
## 128 42358    931 2022091200     128 67.90 26.88333
## 129 42358    931 2022091200     129 67.88 27.21333
## 130 42358    931 2022091200     130 67.86 27.52333
## 131 42358    931 2022091200     131 67.84 27.83333
## 132 42358    931 2022091200     132 67.82 28.11333
cluster2_df<- process_play_data(df, 401, 2022091200)
##     nflId playId     gameId frameId     x     y
## 1   52423    401 2022091200       1 34.01 29.16
## 2   52423    401 2022091200       2 34.04 28.90
## 3   52423    401 2022091200       3 34.06 28.63
## 4   52423    401 2022091200       4 34.07 28.33
## 5   52423    401 2022091200       5 34.08 28.02
## 6   52423    401 2022091200       6 34.08 27.70
## 7   52423    401 2022091200       7 34.08 27.36
## 8   52423    401 2022091200       8 34.06 27.01
## 9   52423    401 2022091200       9 34.04 26.65
## 10  52423    401 2022091200      10 34.01 26.29
## 11  52423    401 2022091200      11 33.96 25.93
## 12  52423    401 2022091200      12 33.91 25.58
## 13  52423    401 2022091200      13 33.84 25.23
## 14  52423    401 2022091200      14 33.76 24.90
## 15  52423    401 2022091200      15 33.67 24.57
## 16  52423    401 2022091200      16 33.58 24.25
## 17  52423    401 2022091200      17 33.48 23.94
## 18  52423    401 2022091200      18 33.37 23.64
## 19  52423    401 2022091200      19 33.26 23.34
## 20  52423    401 2022091200      20 33.15 23.05
## 21  52423    401 2022091200      21 33.03 22.78
## 22  52423    401 2022091200      22 32.90 22.51
## 23  52423    401 2022091200      23 32.77 22.26
## 24  52423    401 2022091200      24 32.64 22.01
## 25  52423    401 2022091200      25 32.52 21.77
## 26  52423    401 2022091200      26 32.40 21.55
## 27  52423    401 2022091200      27 32.28 21.34
## 28  52423    401 2022091200      28 32.15 21.14
## 29  52423    401 2022091200      29 32.03 20.95
## 30  52423    401 2022091200      30 31.92 20.78
## 31  52423    401 2022091200      31 31.80 20.61
## 32  52423    401 2022091200      32 31.68 20.47
## 33  52423    401 2022091200      33 31.57 20.33
## 34  52423    401 2022091200      34 31.46 20.20
## 35  52423    401 2022091200      35 31.36 20.08
## 36  52423    401 2022091200      36 31.27 19.96
## 37  52423    401 2022091200      37 31.18 19.85
## 38  52423    401 2022091200      38 31.10 19.75
## 39  52423    401 2022091200      39 31.02 19.65
## 40  52423    401 2022091200      40 30.95 19.56
## 41  52423    401 2022091200      41 30.88 19.49
## 42  52423    401 2022091200      42 30.81 19.41
## 43  52423    401 2022091200      43 30.75 19.35
## 44  52423    401 2022091200      44 30.68 19.30
## 45  52423    401 2022091200      45 30.61 19.25
## 46  52423    401 2022091200      46 30.54 19.21
## 47  52423    401 2022091200      47 30.46 19.18
## 48  52423    401 2022091200      48 30.38 19.16
## 49  52423    401 2022091200      49 30.31 19.15
## 50  52423    401 2022091200      50 30.25 19.14
## 51  52423    401 2022091200      51 30.19 19.14
## 52  52423    401 2022091200      52 30.16 19.14
## 53  52423    401 2022091200      53 30.14 19.14
## 54  52423    401 2022091200      54 30.13 19.14
## 55  52423    401 2022091200      55 30.13 19.15
## 56  52423    401 2022091200      56 30.14 19.15
## 57  52423    401 2022091200      57 30.15 19.15
## 58  52423    401 2022091200      58 30.16 19.14
## 59  52423    401 2022091200      59 30.17 19.14
## 60  52423    401 2022091200      60 30.18 19.13
## 61  52423    401 2022091200      61 30.19 19.13
## 62  52423    401 2022091200      62 30.20 19.12
## 63  52423    401 2022091200      63 30.20 19.11
## 64  52423    401 2022091200      64 30.20 19.10
## 65  52423    401 2022091200      65 30.20 19.09
## 66  52423    401 2022091200      66 30.20 19.09
## 67  52423    401 2022091200      67 30.19 19.08
## 68  52423    401 2022091200      68 30.19 19.08
## 69  52423    401 2022091200      69 30.18 19.08
## 70  52423    401 2022091200      70 30.18 19.09
## 71  52423    401 2022091200      71 30.18 19.10
## 72  52423    401 2022091200      72 30.18 19.10
## 73  52423    401 2022091200      73 30.18 19.10
## 74  52423    401 2022091200      74 30.18 19.10
## 75  52423    401 2022091200      75 30.18 19.10
## 76  52423    401 2022091200      76 30.19 19.10
## 77  52423    401 2022091200      77 30.19 19.08
## 78  52423    401 2022091200      78 30.19 19.07
## 79  52423    401 2022091200      79 30.19 19.06
## 80  52423    401 2022091200      80 30.20 19.06
## 81  52423    401 2022091200      81 30.20 19.05
## 82  52423    401 2022091200      82 30.19 19.05
## 83  52423    401 2022091200      83 30.19 19.05
## 84  52423    401 2022091200      84 30.19 19.05
## 85  52423    401 2022091200      85 30.19 19.06
## 86  52423    401 2022091200      86 30.19 19.07
## 87  52423    401 2022091200      87 30.18 19.09
## 88  52423    401 2022091200      88 30.18 19.10
## 89  52423    401 2022091200      89 30.18 19.12
## 90  52423    401 2022091200      90 30.19 19.16
## 91  52423    401 2022091200      91 30.22 19.20
## 92  52423    401 2022091200      92 30.26 19.28
## 93  52423    401 2022091200      93 30.31 19.38
## 94  52423    401 2022091200      94 30.37 19.52
## 95  52423    401 2022091200      95 30.46 19.70
## 96  52423    401 2022091200      96 30.56 19.91
## 97  52423    401 2022091200      97 30.67 20.18
## 98  52423    401 2022091200      98 30.78 20.50
## 99  52423    401 2022091200      99 30.89 20.89
## 100 52423    401 2022091200     100 31.00 21.34
## 101 52423    401 2022091200     101 31.11 21.83
## 102 52423    401 2022091200     102 31.21 22.36
## 103 52423    401 2022091200     103 31.30 22.93
## 104 52423    401 2022091200     104 31.37 23.54
## 105 52423    401 2022091200     105 31.43 24.19
## 106 52423    401 2022091200     106 31.49 24.87
## 107 52423    401 2022091200     107 31.53 25.57
cluster3_df <- process_play_data(df, 85, 2022091200)
##     nflId playId     gameId frameId     x        y
## 1   46096     85 2022091200       1 86.73 30.21333
## 2   46096     85 2022091200       2 86.75 30.22333
## 3   46096     85 2022091200       3 86.76 30.23333
## 4   46096     85 2022091200       4 86.78 30.23333
## 5   46096     85 2022091200       5 86.81 30.23333
## 6   46096     85 2022091200       6 86.84 30.22333
## 7   46096     85 2022091200       7 86.88 30.22333
## 8   46096     85 2022091200       8 86.91 30.21333
## 9   46096     85 2022091200       9 86.93 30.21333
## 10  46096     85 2022091200      10 86.97 30.21333
## 11  46096     85 2022091200      11 87.00 30.22333
## 12  46096     85 2022091200      12 87.03 30.24333
## 13  46096     85 2022091200      13 87.05 30.27333
## 14  46096     85 2022091200      14 87.07 30.30333
## 15  46096     85 2022091200      15 87.08 30.35333
## 16  46096     85 2022091200      16 87.08 30.40333
## 17  46096     85 2022091200      17 87.08 30.47333
## 18  46096     85 2022091200      18 87.07 30.54333
## 19  46096     85 2022091200      19 87.05 30.61333
## 20  46096     85 2022091200      20 87.03 30.69333
## 21  46096     85 2022091200      21 87.00 30.77333
## 22  46096     85 2022091200      22 86.97 30.85333
## 23  46096     85 2022091200      23 86.94 30.92333
## 24  46096     85 2022091200      24 86.90 31.00333
## 25  46096     85 2022091200      25 86.87 31.07333
## 26  46096     85 2022091200      26 86.84 31.14333
## 27  46096     85 2022091200      27 86.81 31.21333
## 28  46096     85 2022091200      28 86.79 31.30333
## 29  46096     85 2022091200      29 86.78 31.38333
## 30  46096     85 2022091200      30 86.76 31.46333
## 31  46096     85 2022091200      31 86.76 31.54333
## 32  46096     85 2022091200      32 86.75 31.62333
## 33  46096     85 2022091200      33 86.75 31.68333
## 34  46096     85 2022091200      34 86.75 31.73333
## 35  46096     85 2022091200      35 86.75 31.77333
## 36  46096     85 2022091200      36 86.75 31.80333
## 37  46096     85 2022091200      37 86.74 31.82333
## 38  46096     85 2022091200      38 86.74 31.83333
## 39  46096     85 2022091200      39 86.73 31.83333
## 40  46096     85 2022091200      40 86.73 31.81333
## 41  46096     85 2022091200      41 86.72 31.80333
## 42  46096     85 2022091200      42 86.70 31.79333
## 43  46096     85 2022091200      43 86.68 31.77333
## 44  46096     85 2022091200      44 86.66 31.76333
## 45  46096     85 2022091200      45 86.64 31.75333
## 46  46096     85 2022091200      46 86.62 31.75333
## 47  46096     85 2022091200      47 86.60 31.75333
## 48  46096     85 2022091200      48 86.59 31.77333
## 49  46096     85 2022091200      49 86.57 31.78333
## 50  46096     85 2022091200      50 86.56 31.79333
## 51  46096     85 2022091200      51 86.56 31.79333
## 52  46096     85 2022091200      52 86.55 31.80333
## 53  46096     85 2022091200      53 86.55 31.80333
## 54  46096     85 2022091200      54 86.56 31.80333
## 55  46096     85 2022091200      55 86.56 31.80333
## 56  46096     85 2022091200      56 86.57 31.80333
## 57  46096     85 2022091200      57 86.57 31.79333
## 58  46096     85 2022091200      58 86.58 31.80333
## 59  46096     85 2022091200      59 86.59 31.80333
## 60  46096     85 2022091200      60 86.60 31.80333
## 61  46096     85 2022091200      61 86.60 31.81333
## 62  46096     85 2022091200      62 86.61 31.81333
## 63  46096     85 2022091200      63 86.62 31.82333
## 64  46096     85 2022091200      64 86.62 31.82333
## 65  46096     85 2022091200      65 86.63 31.83333
## 66  46096     85 2022091200      66 86.64 31.83333
## 67  46096     85 2022091200      67 86.64 31.82333
## 68  46096     85 2022091200      68 86.64 31.81333
## 69  46096     85 2022091200      69 86.64 31.81333
## 70  46096     85 2022091200      70 86.63 31.79333
## 71  46096     85 2022091200      71 86.63 31.77333
## 72  46096     85 2022091200      72 86.62 31.76333
## 73  46096     85 2022091200      73 86.62 31.74333
## 74  46096     85 2022091200      74 86.61 31.73333
## 75  46096     85 2022091200      75 86.60 31.72333
## 76  46096     85 2022091200      76 86.59 31.71333
## 77  46096     85 2022091200      77 86.58 31.71333
## 78  46096     85 2022091200      78 86.58 31.70333
## 79  46096     85 2022091200      79 86.57 31.71333
## 80  46096     85 2022091200      80 86.57 31.71333
## 81  46096     85 2022091200      81 86.56 31.72333
## 82  46096     85 2022091200      82 86.56 31.73333
## 83  46096     85 2022091200      83 86.56 31.74333
## 84  46096     85 2022091200      84 86.56 31.75333
## 85  46096     85 2022091200      85 86.56 31.76333
## 86  46096     85 2022091200      86 86.55 31.76333
## 87  46096     85 2022091200      87 86.55 31.76333
## 88  46096     85 2022091200      88 86.54 31.77333
## 89  46096     85 2022091200      89 86.53 31.77333
## 90  46096     85 2022091200      90 86.53 31.78333
## 91  46096     85 2022091200      91 86.51 31.78333
## 92  46096     85 2022091200      92 86.50 31.78333
## 93  46096     85 2022091200      93 86.49 31.77333
## 94  46096     85 2022091200      94 86.48 31.73333
## 95  46096     85 2022091200      95 86.47 31.68333
## 96  46096     85 2022091200      96 86.46 31.60333
## 97  46096     85 2022091200      97 86.46 31.49333
## 98  46096     85 2022091200      98 86.46 31.34333
## 99  46096     85 2022091200      99 86.46 31.14333
## 100 46096     85 2022091200     100 86.45 30.89333
## 101 46096     85 2022091200     101 86.44 30.59333
## 102 46096     85 2022091200     102 86.44 30.24333
## 103 46096     85 2022091200     103 86.44 29.84333
## 104 46096     85 2022091200     104 86.43 29.40333
## 105 46096     85 2022091200     105 86.42 28.91333
## 106 46096     85 2022091200     106 86.41 28.40333
## 107 46096     85 2022091200     107 86.40 27.85333
## 108 46096     85 2022091200     108 86.39 27.28333
## 109 46096     85 2022091200     109 86.38 26.69333
## 110 46096     85 2022091200     110 86.37 26.09333
## 111 46096     85 2022091200     111 86.36 25.48333
## 112 46096     85 2022091200     112 86.35 24.86333
## 113 46096     85 2022091200     113 86.34 24.23333
## 114 46096     85 2022091200     114 86.34 23.60333
## 115 46096     85 2022091200     115 86.34 22.97333
## 116 46096     85 2022091200     116 86.34 22.34333
plot_grid_overlay(cluster1_df)

plot_grid_overlay(cluster2_df)

plot_grid_overlay(cluster3_df)