spurtle |>
dplyr::mutate(logo = team_name) |>
dplyr::slice(1:15) |>
dplyr::select(logo, team_name, delta, pts_spurt, total_xpl, opp_pts_spurt,
opp_total_xpl) |>
gt::gt() |>
cfbplotR::gt_fmt_cfb_logo(columns = c("logo")) |>
gt::cols_label(
logo = "",
team_name = "",
delta = "+/-",
pts_spurt = "Pts/Spurt",
total_xpl = "Spurts",
opp_pts_spurt = "Pts/Spurt",
opp_total_xpl = "Spurts",
) |>
gt::tab_spanner(label = "Offense",
columns = c(pts_spurt, total_xpl)) |>
gt::tab_spanner(label = "Defense",
columns = c(opp_pts_spurt, opp_total_xpl)) |>
gt::fmt_number(columns = c(delta, pts_spurt, opp_pts_spurt),
decimals = 1,
use_seps = FALSE) |>
gt::cols_nanoplot(
columns = c(pts_spurt, opp_pts_spurt),
new_col_name = "Spurts",
new_col_label = "Spurtability",
plot_type = "bar",
options = gt::nanoplot_options(
show_data_line = FALSE,
show_data_area = FALSE,
data_bar_stroke_color = "transparent",
data_bar_fill_color = c("lightgreen", "lightpink")
)
) |>
gt::data_color(
columns = c(delta),
fn = scales::col_numeric(
c(
"lightpink",
"lightgreen"
),
domain = c(11:1)
)
) |>
gtExtras::gt_theme_538() |>
gt::tab_header(
title = "Spurtability of FBS Teams",
subtitle = "Spurtability measures a team's ability to create,
score, and prevent big drives."
) |>
gt::tab_source_note(source_note = "Bless your chart | October 16, 2023") |>
gt::tab_style(
style = list(
gt::cell_borders(
sides = c("left"),
color = "#c1c1c1",
weight = gt::px(2)
)
),
locations = list(
gt::cells_body(
columns = c(pts_spurt, opp_pts_spurt, Spurts)
)
)
) -> spurt_table
gtExtras::gtsave_extra(spurt_table,
filename = "spurt_table.png", vheight = 875, vwidth = 775)
spurt_table