# prepare the table by grabbing the widest range and slimmest range 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=/i/teamlogos/ncaa/500/153.png' style='height: 55px; 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;'>North Carolina defense under each coach since 1988</span> <span style='font-size: 14px; font-weight: normal; display: block; text-align: center;'>Shows the defensive performance using SP+ ratings and percentiles since the 1988 season.</span> </div> <div> <img src='https://a.espncdn.com/combiner/i?img=/redesign/assets/img/icons/ESPN-icon-football-college.png' style='height: 45px; width: auto; vertical-align: middle;'> </div> </div> <br>")unc_defense |> dplyr::relocate(rank, .before = coach) |> dplyr::relocate(record, .before = avg_rtg) |> dplyr::relocate(win_pct, .before = avg_rtg) |> gt::gt() |> gt::cols_hide(rank) |> gtExtras::gt_merge_stack(col1 = coach,col2 = tenure,palette =c("black", "#848484") ) |> gtExtras::gt_merge_stack(col1 = record,col2 = win_pct,palette =c("black", "#848484") ) |> gtExtras::gt_add_divider(columns =c(coach), sides ="right", color ="black") |> gt::cols_label(coach ="Coach",record ="Overall Record",avg_rtg ="Rating",avg_pct ="Percentile",sum_data ="", ) |> gt::tab_spanner(columns =c(avg_rtg, avg_pct, sum_data),label = gt::html("SP+ Defense<br>Averages over tenure")) |> gt::cols_nanoplot(columns = sum_data,reference_line =70,autohide =TRUE,plot_type ="line",new_col_label ="Performance",options = gt::nanoplot_options(data_area_fill_color ="#eabfff",reference_line_color ="#333333",show_data_area =TRUE,show_data_points =FALSE ) ) |> gt::fmt_number(columns =c(avg_rtg, avg_pct), decimals =1) |> gt::tab_header(title = gt::html(custom_header)) |> gt::tab_source_note(source_note = gt::html("<hr> Data from Bill Connelly's SP+ system | Theme from cbbplotR and logos from ESPN.com<br> Shows the average <b>defensive</b> SP+ rating and percentile over the coaching tenure.<br> The <b>lower</b> average SP+ rating, the <b>better</b> the defense.<br> The dotted line is the <b>70th percentile</b> and the <b>higher</b> the percentile, the <b>better</b> the defense.<br> <hr> <b>Table by Chris (@dadgumboxscores) + Bless your chart | August 28, 2024</b>")) |> cbbplotR::gt_theme_savant() |> gt::tab_style(style = gt::cell_borders(sides ="top", color ='black', weight = gt::px(1.5), style ='solid'),locations = gt::cells_body(rows = gt::everything() ) ) |> gt::tab_style(style =list( gt::cell_text(color ="#333333", size = gt::px(12), weight ="bold"), gt::cell_borders(sides ="bottom", color ="black", weight = gt::px(2)) ),locations =list( gt::cells_column_spanners(spanners = gt::everything() ) ) ) |> gt::tab_options(heading.align ="center", ) -> unc_def_tblgtExtras::gtsave_extra(unc_def_tbl, filename ="unc_def_tbl.png",vwidth =750,expand =10)unc_def_tbl
North Carolina defense under each coach since 1988Shows the defensive performance using SP+ ratings and percentiles since the 1988 season.
Coach
Overall Record
SP+ Defense
Averages over tenure
Performance
Rating
Percentile
Mack Brown 2.0
2019-Present
38-27
0.585
27.8
50.5
Larry Fedora
2012-2018
45-43
0.511
27.2
54.0
Everett Withers
2011
7-6
0.539
23.0
67.4
Butch Davis
2007-2010
28-23
0.549
19.1
79.0
John Bunting
2001-2006
27-45
0.375
27.1
45.2
Carl Torbush
1998-2000
17-18
0.486
23.1
60.2
Mack Brown 1.0
1988-1997
69-46
0.600
18.8
67.3
Data from Bill Connelly's SP+ system | Theme from cbbplotR and logos from ESPN.com
Shows the average defensive SP+ rating and percentile over the coaching tenure.
The lower average SP+ rating, the better the defense.
The dotted line is the 70th percentile and the higher the percentile, the better the defense. Table by Chris (@dadgumboxscores) + Bless your chart | August 28, 2024