nw_tbl <- net_wab_data |>
dplyr:: filter (team %in% bub_teams) |>
dplyr:: mutate (
record = paste0 (wins, "-" , losses),
q1_record = paste0 (q1_win, "-" , q1_loss),
q2_record = paste0 (q2_win, "-" , q2_loss),
q3_record = paste0 (q3_win, "-" , q3_loss),
q4_record = paste0 (q4_win, "-" , q4_loss)
) |>
dplyr:: select (
team, total, record, quad_1, q1_record,
quad_2, q2_record,
quad_3, q3_record,
quad_4, q4_record,
)
custom_header <- glue:: glue (
"<div style='display: flex; justify-content: space-between; align-items: center;'>
<div>
<img src='https://a.espncdn.com/combiner/i?img=/redesign/assets/img/icons/ESPN-icon-basketball.png'
style='height: 40px; width: auto; vertical-align: middle;'>
</div>
<div style='flex-grow:1; margin-left: 30px; margin-right: 30px'>
<span style='display: block; font-weight: bold; text-align: center; font-size: 24px;'>Bubble Teams: WAB by Quadrant</span>
<span style='font-size: 14px; font-weight: normal; display: block; text-align: center;'>Shows the WAB earned by games played in each quadrant.</span>
</div>
<div>
<img src='https://a.espncdn.com/combiner/i?img=/redesign/assets/img/icons/ESPN-icon-basketball.png'
style='height: 40px; width: auto; vertical-align: middle;'>
</div>
</div>
<br>"
)
net_tbl <- nw_tbl |>
cbbplotR:: gt_cbb_teams (team, team) |>
dplyr:: arrange (- total) |>
gt:: gt () |>
gtUtils:: gt_theme_gtutils () |>
gt:: fmt_markdown (team) |>
gt:: cols_align (team, align = "left" ) |>
gtExtras:: gt_merge_stack (
col1 = total,
col2 = record,
palette = c ("black" , "#333333" )
) |>
gtExtras:: gt_merge_stack (
col1 = quad_1,
col2 = q1_record,
palette = c ("black" , "#333333" )
) |>
gtExtras:: gt_merge_stack (
col1 = quad_2,
col2 = q2_record,
palette = c ("black" , "#333333" )
) |>
gtExtras:: gt_merge_stack (
col1 = quad_3,
col2 = q3_record,
palette = c ("black" , "#333333" )
) |>
gtExtras:: gt_merge_stack (
col1 = quad_4,
col2 = q4_record,
palette = c ("black" , "#333333" )
) |>
gtUtils:: gt_column_subheaders (
total = list (heading = "WAB" , subtitle = "Overall Record" ),
quad_1 = list (heading = "Quad 1" , subtitle = "WAB + Record" ),
quad_2 = list (heading = "Quad 2" , subtitle = "WAB + Record" ),
quad_3 = list (heading = "Quad 3" , subtitle = "WAB + Record" ),
quad_4 = list (heading = "Quad 4" , subtitle = "WAB + Record" ),
heading_color = "black" ,
subtitle_color = "gray"
) |>
gt:: cols_label (
team = ""
) |>
gtUtils:: gt_border_grid (color = "black" ,
weight = 0.5 ,
include_labels = FALSE ) |>
gtExtras:: gt_add_divider (
columns = c (team),
sides = "right" ,
color = "black"
) |>
gt:: data_color (
columns = c (total, quad_1, quad_2, quad_3, quad_4),
direction = c ("column" ),
method = c ("numeric" ),
palette = c ("#d7191c" , "#fdae61" ,
"#ffffbf" , "#a6d96a" ,
"#1a9641" ),
alpha = 0.6
) |>
gt:: tab_header (title = gt:: html (custom_header)) |>
gt:: tab_source_note (
source_note =
gt:: html (
"<hr>Data via barttorvik.com | theme via {gtUtils} <br>
Quadrants are defined by the NCAA's NET rankings. WAB determined using data from barttorvik.com<br>
<hr><b>Table by Chris at Bless your chart | data through March 15 games</b>"
)
) |>
gtUtils:: gt_border_bars_bottom (c ("#636363" , "#969696" , "#cccccc" )) |>
gt:: tab_options (table.width = gt:: px (675 )) |>
gt:: tab_style (
locations = gt:: cells_source_notes (),
style = gt:: cell_text (
font = gt:: google_font ("Signika Negative" ),
size = gt:: px (11.5 ),
weight = 250
)
) |>
gt:: tab_style (
style = list (
gt:: cell_text (font = gt:: google_font ("Signika Negative" ),
size = gt:: px (14 )
)
),
locations = gt:: cells_body (
rows = gt:: everything (),
columns = gt:: everything ()
)
)
gtUtils:: gt_save_crop (
net_tbl,
file = "net_tbl.png" ,
whitespace = 40 ,
bg = "#FFFDF5"
)
net_tbl