083: ACC Tournament

cbbplotR
gt
Published

March 11, 2024

ACC Tournament data

Code
library(cbbplotR)

acc_seeds <- readr::read_csv("acct-seeds.csv")

cbbdata::cbd_torvik_game_stats(type = "conf_t") |> 
  dplyr::filter(conf == "ACC" & year > 2013) -> acct
API Key set!
Code
acct_with_seeds <- acct |> 
  dplyr::left_join(acc_seeds, by= c("team", "year"))

# need to add in winners
winners <- tibble::tribble(
  ~seed,~titles,
  1,4,
  2,0,
  3,2,
  4,2,
  5,1,
  6,0,
  7,1,
  8,0,
  9,0,
  10,0,
  11,0,
  12,0,
  13,0,
  14,0,
  15,0
)

acct_with_seeds |>
  dplyr::group_by(seed) |>
  dplyr::summarise(
    W = sum(result == "W"),
    L = sum(result == "L"),
    win_pct = W / (W + L)
  ) |>
  dplyr::left_join(winners, by = "seed") |>
  dplyr::ungroup() -> seed_tbl

# winners 
teamTitles <- winners <- tibble::tribble(
  ~team,~champs,
  "Virginia",2,
  "Duke",3,
  "Virginia Tech",1,
  "North Carolina",1,
  "Florida St.",1,
  "Georgia Tech",1,
  "Notre Dame",1,
)

# find records and seeds 
acct_with_seeds |>
  dplyr::group_by(team) |>
  dplyr::summarise(
    W = sum(result == "W"),
    L = sum(result == "L"),
    win_pct = W / (W + L), 
    seed_avg = mean(seed),
    min_seed = min(seed),
    max_seed = max(seed),
  ) |>
  dplyr::left_join(teamTitles, by = "team") |>
  dplyr::ungroup() |> 
  dplyr::mutate(champs = tidyr::replace_na(champs, 0)) -> team_tbl

ACC tournament GT Table

Code
acc_title <- gt_cbb_logo_title(title = 'ACC Tournament: Record and Titles by Seed Since 2014',
                           subtitle = "Shows the record and titles by seed of the last ten conference tournaments.",
                           type = 'conference',
                           value = 'ACC',
                           logo_height = 40)

seed_tbl  |> 
  dplyr::mutate(seed = paste0(seed, " ", "seed"),
                record = paste0(W, "-", L),
                trophys = dplyr::case_when(
                  titles %% 1 == 0 ~ strrep("trophy,", titles),
                  titles %% 1 != 0 ~ paste0(strrep("trophy,", floor(titles)), "trophy")), 
                trophys = dplyr::if_else(trophys == "", "0", trophys)) |>
  dplyr::select(seed, record, win_pct, trophys) |> 
  gt::gt() |> 
  gt::fmt_number(columns = c(win_pct), decimals = 3) |> 
  gt::cols_label(
    seed = "",
    record = "Record",
    win_pct = "Win %", 
    trophys = "Titles"
  ) |> 
 gt::fmt_icon(
   columns = c(trophys),
   rows = c(1, 3, 4, 5, 7),
    fill_color = "orange"
 ) |> 
  gtExtras::gt_theme_538() |>
  gtExtras::gt_highlight_rows(rows = c(2, 10), fill = "#FFEBEA", bold_target_only = TRUE,
    target_col = c(seed)) |> 
  gtExtras::gt_hulk_col_numeric(columns = c(win_pct)) |> 
  gt::tab_header(title = gt::html(acc_title)) |> 
    gt::tab_footnote(footnote = "The 2020 Tournament was cancelled after six games due to COVID, number one seed Florida State was awarded the title.",
                   locations = gt::cells_column_labels(columns = trophys)) |> 
  gt::tab_source_note(source_note = gt::html("<hr>14 teams competed in 2015, 2016, and 2020 due to post-season bans (Syracuse, Louisville, Georgia Tech).<br>1 seed (Virginia) and 10 seed (Duke) withdrew from the 2021 Tournament due to COVID.<br>Data provided by cbbdata, cbbplotR, and Wikipedia.<br><hr>
                                             <b>Data viz by Chris at Bless your chart </b>")) -> ACC_tbl


gtExtras::gtsave_extra(ACC_tbl,
                       filename = "acc_tbl.png",
                       vheight = 875,
                       vwidth = 600)

ACC_tbl
ACC Tournament: Record and Titles by Seed Since 2014
Shows the record and titles by seed of the last ten conference tournaments.
Record Win % Titles1
1 seed 18-5 0.783 Trophy Trophy Trophy Trophy
2 seed 9-10 0.474 0
3 seed 14-8 0.636 Trophy Trophy
4 seed 11-8 0.579 Trophy Trophy
5 seed 14-9 0.609 Trophy
6 seed 13-10 0.565 0
7 seed 11-9 0.550 Trophy
8 seed 4-10 0.286 0
9 seed 7-11 0.389 0
10 seed 13-9 0.591 0
11 seed 8-11 0.421 0
12 seed 8-11 0.421 0
13 seed 6-11 0.353 0
14 seed 4-11 0.267 0
15 seed 1-8 0.111 0

14 teams competed in 2015, 2016, and 2020 due to post-season bans (Syracuse, Louisville, Georgia Tech).
1 seed (Virginia) and 10 seed (Duke) withdrew from the 2021 Tournament due to COVID.
Data provided by cbbdata, cbbplotR, and Wikipedia.

Data viz by Chris at Bless your chart
1 The 2020 Tournament was cancelled after six games due to COVID, number one seed Florida State was awarded the title.

Team Table

Code
acc_title <- gt_cbb_logo_title(title = 'ACC Tournament: Record and Titles by Team Since 2014',
                           subtitle = "Shows the record, seed summary, and titles by team of the last ten conference tournaments.",
                           type = 'conference',
                           value = 'ACC',
                           logo_height = 40)

team_tbl  |> 
  dplyr::arrange(-champs, -win_pct) |> 
  dplyr::mutate(record = paste0(W, "-", L),
                trophys = dplyr::case_when(
                  champs %% 1 == 0 ~ strrep("trophy,", champs),
                  champs %% 1 != 0 ~ paste0(strrep("trophy,", floor(champs)), "trophy")), 
                trophys = dplyr::if_else(trophys == "", "0", trophys)) |>
  dplyr::select(team, record, win_pct, min_seed, max_seed,seed_avg, trophys) |> 
  cbbplotR::gt_cbb_teams(team, team) |> 
  gt::gt() |> 
  gt::fmt_markdown(team) |> 
  gt::fmt_number(columns = c(seed_avg), decimals = 1) |> 
  gt::fmt_number(columns = c(win_pct), decimals = 3) |> 
  gt::cols_label(
    team = "",
    record = "Record",
    win_pct = "Win %",
    min_seed = "Best",
    max_seed = "Worst",
    seed_avg = "AVG",
    trophys = "Titles"
  ) |> 
 gt::fmt_icon(
   columns = c(trophys),
   rows = c(1:7),
    fill_color = "orange"
 ) |> 
  gtExtras::gt_theme_nytimes() |>
  gtExtras::gt_hulk_col_numeric(columns = c(win_pct)) |>
  gtExtras::gt_hulk_col_numeric(columns = c(seed_avg), reverse = TRUE) |>
  gt::tab_spanner(columns = c(min_seed, max_seed, seed_avg), label = "Seed Summary") |> 
  gt::cols_align(align = "left", columns = "team") |> 
  gt::tab_header(title = gt::html(acc_title)) |> 
    gt::tab_footnote(footnote = "The 2020 Tournament was cancelled after six games due to COVID, number one seed Florida State was awarded the title.",
                   locations = gt::cells_column_labels(columns = trophys)) |> 
  gt::tab_source_note(source_note = gt::html("<hr>Maryland's last season in the ACC was 2014.<br><br>Syracuse (2015), Louisville (2016), and Georgia Tech (2020) did not participate in the tournament due to post-season bans.<br><br>1 seed (Virginia) and 10 seed (Duke) withdrew from the 2021 Tournament due to COVID.<br><br>Data provided by cbbdata, cbbplotR, and Wikipedia.<br><hr>
                                             <b>Data viz by Chris at Bless your chart </b>")) |> 
  gt::tab_style(
      style = gt::cell_text(
        color = "#333333",
        transform = "uppercase"
      ),
      locations = gt::cells_column_labels(everything())
    ) |> 
  gtExtras::gt_add_divider(columns = c(seed_avg), sides = "right", 
                           color = "#333333") |> 
  gtExtras::gt_add_divider(columns = c(min_seed), sides = "left", 
                           color = "#333333") -> teamACC_tbl


gtExtras::gtsave_extra(teamACC_tbl,
                       filename = "teamacc_tbl.png",
                       vheight = 875,
                       vwidth = 600)

teamACC_tbl
ACC Tournament: Record and Titles by Team Since 2014
Shows the record, seed summary, and titles by team of the last ten conference tournaments.
Record Win % Seed Summary Titles1
Best Worst AVG

Duke

19-6 0.760 1 10 3.7 Trophy Trophy Trophy

Virginia

16-7 0.696 1 6 2.3 Trophy Trophy

North Carolina

18-9 0.667 1 14 4.6 Trophy

Notre Dame

12-9 0.571 2 15 8.0 Trophy

Virginia Tech

9-10 0.474 3 15 8.3 Trophy

Florida St.

8-10 0.444 2 12 6.9 Trophy

Georgia Tech

5-9 0.357 4 14 10.7 Trophy

North Carolina St.

11-9 0.550 5 15 8.7 0

Miami FL

9-11 0.450 1 14 7.8 0

Boston College

8-11 0.421 10 15 12.2 0

Pittsburgh

8-11 0.421 4 15 9.5 0

Clemson

6-10 0.375 3 12 7.1 0

Syracuse

5-9 0.357 2 11 7.7 0

Louisville

3-8 0.273 4 15 9.0 0

Wake Forest

4-11 0.267 5 14 10.3 0

Maryland

0-1 0.000 8 8 8.0 0

Maryland's last season in the ACC was 2014.

Syracuse (2015), Louisville (2016), and Georgia Tech (2020) did not participate in the tournament due to post-season bans.

1 seed (Virginia) and 10 seed (Duke) withdrew from the 2021 Tournament due to COVID.

Data provided by cbbdata, cbbplotR, and Wikipedia.

Data viz by Chris at Bless your chart
1 The 2020 Tournament was cancelled after six games due to COVID, number one seed Florida State was awarded the title.