Code
::p_load(gt, gtExtras, janitor, tidyverse, readxl)
pacman
<- read_excel("data.xlsx") data
This table presents the first-round results of the 2024 NFL Draft alongside the final 2024 NFL Mock Draft predictions from the four most popular draft analysts. Although mock drafts offer engaging content throughout the draft season, their accuracy typically declines after the top four picks.
The purpose of this table was to experiment with {gt} and {gtExtra} to create an engaging data visual
Data was collected and complied from NFL.com and Sharp Football.
This table was built in R using {gt} and {gtExtras}.
Data wrangling was completed using {janitor}, {readxl}, and {tidyverse}.
::p_load(gt, gtExtras, janitor, tidyverse, readxl)
pacman
<- read_excel("data.xlsx") data
<- data |>
data clean_names() |>
as_tibble() |>
arrange(actual) |>
mutate(across(5:9, as.numeric)) |>
mutate(across(everything(), ~ ifelse(is.na(.), 0, .))) |>
pivot_longer(cols = -c(players, actual_1, who_was_correct, mean_projection),
names_to = 'draft',
values_to = 'position') |>
group_by(players, actual_1, who_was_correct, mean_projection) |>
summarise(positions = list(position)) |>
ungroup() |>
mutate(mean_projection = as.numeric(mean_projection)) |>
mutate(mean_projection_1 = mean_projection) |>
mutate(change_score = abs(mean_projection_1 - actual_1)) |>
select(players, mean_projection, actual_1, change_score, positions, who_was_correct)
<- c("#3B9AB2", "#F21A00", "#FF0000") color_palette
|>
data arrange(actual_1) |>
gt() |>
tab_header(
title = md('**All Mocks are Wrong, but Some are Useful**'),
subtitle = md("*The final 2024 <span style='font-family: Times New Roman;'>**NFL**</span> Mock Drafts from Daniel Jeremiah (DJ), Peter Schrager (PS), Mel Kiper (MK), Bucky Brooks (BB)*")) |>
tab_options(
heading.align = "Center",
heading.title.font.size = px(24),
heading.background.color = "#5BBCD6") |>
opt_table_font(font = google_font(name = "Playfair Display")) |>
cols_label(
players = 'Player Name',
actual_1 = 'Actual Draft Position',
change_score = 'Difference',
who_was_correct = 'Who Predicted Correctly',
mean_projection = 'Average Projected Draft Position',
positions = md('Projected Position <br> (DJ, PS, MK, BB, Actual)'),
|>
) gt_plt_sparkline(column = positions, palette = c("#FF0000", "#00A08A", "#F2AD00", "#F98400", "#5BBCD6"))|>
gt_color_rows(
columns = c(actual_1, mean_projection),
domain = c(0, 100),
palette = color_palette) |>
opt_stylize(style = 6) |>
gt_plt_bar_pct(change_score, fill="#5BBCD6", scaled = FALSE) |>
cols_align(align = "center", columns = c(mean_projection, actual_1, change_score)) |>
tab_source_note(source_note = ("Data: NFL.com and Sharp Football | Table created by Nicholas Vietto for the 2024 Posit Table Contest"))
All Mocks are Wrong, but Some are Useful | |||||
---|---|---|---|---|---|
The final 2024 NFL Mock Drafts from Daniel Jeremiah (DJ), Peter Schrager (PS), Mel Kiper (MK), Bucky Brooks (BB) | |||||
Player Name | Average Projected Draft Position | Actual Draft Position | Difference | Projected Position (DJ, PS, MK, BB, Actual) |
Who Predicted Correctly |
Caleb Williams | 1 | 1 | All | ||
Jayden Daniels | 2 | 2 | All | ||
Drake Maye | 3 | 3 | All | ||
Marvin Harrison Jr. | 4 | 4 | All | ||
Joe Alt | 7 | 5 | Bucky Brooks | ||
Malik Nabers | 6 | 6 | All | ||
J.C. Lathan | 8 | 7 | None | ||
Michael Penix Jr. | 13 | 8 | None | ||
Rome Odunze | 9 | 9 | Peter Schrager, Mel Kiper, Bucky Brooks | ||
JJ McCarthy | 8 | 10 | None | ||
Olumuyiwa Fashanu | 12 | 11 | None | ||
Bo Nix | 17 | 12 | Peter Schrager | ||
Brock Bowers | 11 | 13 | None | ||
Taliese Fuaga | 12 | 14 | None | ||
Laiatu Latu | 24 | 15 | None | ||
Byron Murphy | 14 | 16 | None | ||
Dallas Turner | 10 | 17 | None | ||
Amarius Mims | 20 | 18 | None | ||
Jared Verse | 20 | 19 | None | ||
Troy Fautanu | 17 | 20 | None | ||
Demeioun 'Chop' Robinson | 26 | 21 | None | ||
Quinyon Mitchell | 16 | 22 | None | ||
Brain Thomas Jr. | 23 | 23 | None | ||
Terrion Arnold | 16 | 24 | None | ||
Jordan Morgan | 31 | 25 | None | ||
Graham Barton | 23 | 26 | Peter Schrager | ||
Darius Robinson | 27 | 27 | Peter Schrager, Mel Kiper, Bucky Brooks | ||
Xavier Worthy | 23 | 28 | None | ||
Tyler Guyton | 22 | 29 | None | ||
Nate Wiggins | 24 | 30 | Daniel Jeremiah | ||
Ricky Pearsall | 0 | 31 | None | ||
Xavier Legette | 32 | 32 | Peter Schrager, Mel Kiper | ||
Data: NFL.com and Sharp Football | Table created by Nicholas Vietto for the 2024 Posit Table Contest |