library(rlang)library(cbbplotR)options(chromote.headless ="new")# scrape data manually # https://www.ncaa.com/news/basketball-men/article/2024-10-14/kansas-alabama-uconn-lead-mens-basketball-ap-preseason-poll# rankings_pivoted <- rankings |> # dplyr::mutate(# `Sweet 16` = ifelse(Season_Finish == "Sweet 16", 1, 0),# `Round of 32` = ifelse(Season_Finish %in% c("Sweet 16", "Round of 32"), 1, 0),# `Round of 64` = ifelse(Season_Finish %in% c("Sweet 16", "Round of 32", "Round of 64"), 1, 0),# `First Four` = ifelse(Season_Finish == "First Four", 1, 0),# `Missed Tournament` = ifelse(Season_Finish == "Missed Tournament", 1, 0)# ) |> # dplyr::select(Rank, Team, `Sweet 16`, `Round of 32`, `Round of 64`, `First Four`, `Missed Tournament`)# load via csv for easier handling in quarto rpivot <- readr::read_csv("rpivot.csv")# NCAAT shooting data with assist from cobrastats ncaatg <- readr::read_csv("ncaat-shooting.csv")ncaalog <- ncaatg |> dplyr::mutate(round = dplyr::case_match(round,"0. FIRST FOUR"~"First4","1. ROUND OF 64"~"R64","2. ROUND OF 32"~"R32","3. SWEET SIXTEEN"~"S16","4. ELITE EIGHT"~"E8","5. FINAL FOUR"~"Final4","6. CHAMPIONSHIP"~"F2" )) |> dplyr::group_by(year, round) |> dplyr::summarise(made_3 =sum(tpm),attempt_3 =sum(tpa),pct_3 = made_3 / attempt_3 ) |> dplyr::arrange(year)ncaalog_wide <- ncaalog |> dplyr::filter(year >2010) |> dplyr::mutate(made_attempt =paste0(made_3, "-", attempt_3)) |> dplyr::select(year, round, made_attempt, pct_3) |> tidyr::pivot_wider(names_from = round, values_from =c(made_attempt, pct_3),names_glue ="{round}_{.value}" ) |> dplyr::select( year, First4_made_attempt, First4_pct_3, R64_made_attempt, R64_pct_3, R32_made_attempt, R32_pct_3, S16_made_attempt, S16_pct_3, E8_made_attempt, E8_pct_3, Final4_made_attempt, Final4_pct_3, F2_made_attempt, F2_pct_3 ) |> dplyr::ungroup()
Table for AP Poll
Code
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;'>NCAA Tournament Performance of the AP Preseason Top-25 Teams</span> <span style='font-size: 14px; font-weight: normal; display: block; text-align: center;'>11 teams ranked in the 2024-25 preseason AP Top-25 poll are still playing in the 2025 NCAA Tournament.</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>")ap_poll_tbl <- rpivot |> cbbplotR::gt_cbb_teams(Team, Team, logo_height =20) |> gt::gt() |> gt::fmt_markdown(columns = Team) |> gtUtils::gt_theme_gtutils() |> gtUtils::gt_indicator_boxes(key_columns =c("Rank", "Team"),color_yes ="lightgreen",color_no ="lightpink",color_na ="#e1e1e1",border_color ="black",border_width =0.5,box_width =16,box_height =16 ) |> gt::cols_align(Team, align ="left") |> gt::cols_align(Rank, align ="right") |> gtUtils::gt_column_subheaders(Rank =list(heading ="Rank", subtitle ="AP Top-25"),`Missed Tournament`=list(heading ="Missed", subtitle ="NCAA Tournament"),`First Four`=list(heading ="First Four", subtitle ="Round of 68"),`Round of 64`=list(heading ="1st Round", subtitle ="Round of 64"),`Round of 32`=list(heading ="2nd Round", subtitle ="Round of 32"),`Sweet 16`=list(heading ="Sweet 16", subtitle ="2nd Weekend"),heading_color ="black",subtitle_color ="gray" ) |> gt::tab_header(title = gt::html(custom_header)) |> gt::tab_source_note(source_note = gt::html("<hr>11 of the top-25 teams are still playing and advanced to the Sweet 16.<br>Seven of the top-25 teams advanced to the Round of 32.<br>Four teams were knocked out in the 1st Round or First Four.<br>Three teams missed the tournament entirely.<br><hr><b>Table by Chris at Bless your Chart | data NCAA.com | March 26, 2025</b>" ) ) |> gtExtras::gt_add_divider(columns =c(`Round of 64`),sides ="right",color ="black" ) |> gtUtils::gt_border_bars_bottom(c("#636363", "#969696", "#cccccc")) |> gt::tab_options(table.width = gt::px(575)) |> gt::tab_style(locations = gt::cells_row_groups(),style =list( gt::cell_text(font = gt::google_font("Signika Negative"),weight =850,size = gt::px(11.5),color ="black",align ="left" ), gt::cell_fill(color ="#C5C5FF") ) ) |> gt::tab_style(locations = gt::cells_column_spanners(),style = gt::cell_text(font = gt::google_font("Signika Negative"),weight =850,size = gt::px(14) ) ) |> gt::tab_style(locations = gt::cells_source_notes(),style = gt::cell_text(font = gt::google_font("Signika Negative"),size = gt::px(10),weight =250 ) ) |> gt::tab_style(style =list(gt::cell_text(font = gt::google_font("Signika Negative"),size = gt::px(11.5) )),locations = gt::cells_body(rows = gt::everything(),columns = gt::everything() ) ) |> gtUtils::gt_border_grid(color ="black",weight =2,include_labels =FALSE) |> gt::tab_style(style = gt::cell_fill(color ="#fdeba9", alpha =0.6), # SEC colorlocations = gt::cells_body(columns = Team, rows =c(2, 4, 7, 10:12,14, 16, 21,23, 24)) ) |> gt::tab_style(style = gt::cell_fill(color ="lightpink", alpha =0.6), # SEC colorlocations = gt::cells_body(columns = Team, rows =c(17, 20, 25)) )gtUtils::gt_save_crop( ap_poll_tbl,file ="ap_poll_tbl.png",whitespace =60,bg ="#FFFDF5")ap_poll_tbl
NCAA Tournament Performance of the AP Preseason Top-25 Teams11 teams ranked in the 2024-25 preseason AP Top-25 poll are still playing in the 2025 NCAA Tournament.
Rank AP Top-25
Team
Sweet 16 2nd Weekend
2nd Round Round of 32
1st Round Round of 64
First Four Round of 68
Missed NCAA Tournament
1
Kansas
2
Alabama
3
Connecticut
4
Houston
5
Iowa St.
6
Gonzaga
7
Duke
8
Baylor
9
North Carolina
10
Arizona
11
Auburn
12
Tennessee
13
Texas A&M
14
Purdue
15
Creighton
16
Arkansas
17
Indiana
18
Marquette
19
Texas
20
Cincinnati
21
Florida
22
UCLA
23
Kentucky
24
Mississippi
25
Rutgers
11 of the top-25 teams are still playing and advanced to the Sweet 16.
Seven of the top-25 teams advanced to the Round of 32.
Four teams were knocked out in the 1st Round or First Four.
Three teams missed the tournament entirely. Table by Chris at Bless your Chart | data NCAA.com | March 26, 2025
NCAAT 3PT shooting table
Code
ncaat_shots_tbl <- ncaalog_wide |> dplyr::mutate(across(ends_with("made_attempt"), ~ tidyr::replace_na(., "-")),across(ends_with("pct_3"), ~ tidyr::replace_na(., 0))) |> dplyr::arrange(-year) |> gt::gt() |> gtExtras::gt_theme_dot_matrix() |> gtExtras::gt_merge_stack(col1 = First4_pct_3,col2 = First4_made_attempt,palette =c("black", "#333333") ) |> gtExtras::gt_merge_stack(col1 = R64_pct_3,col2 = R64_made_attempt,palette =c("black", "#333333") ) |> gtExtras::gt_merge_stack(col1 = R32_pct_3,col2 = R32_made_attempt,palette =c("black", "#333333") ) |> gtExtras::gt_merge_stack(col1 = S16_pct_3,col2 = S16_made_attempt,palette =c("black", "#333333") ) |> gtExtras::gt_merge_stack(col1 = E8_pct_3,col2 = E8_made_attempt,palette =c("black", "#333333") ) |> gtExtras::gt_merge_stack(col1 = Final4_pct_3,col2 = Final4_made_attempt,palette =c("black", "#333333") ) |> gtExtras::gt_merge_stack(col1 = F2_pct_3,col2 = F2_made_attempt,palette =c("black", "#333333") ) |> gt::fmt_percent(columns =ends_with("pct_3"), decimals =1) |> gt::fmt(columns =ends_with("pct_3"),fns =function(x) { dplyr::case_when( x ==0~"-", # Replace 0.0% with "-"TRUE~ scales::percent(x, accuracy =0.1) # Format as percentage ) } ) |> gt::data_color(columns =ends_with("pct_3"),palette =c("#d7191c", "#fdae61", "#ffffbf", "#a6d96a", "#1a9641"),# Middle color is neutralalpha =0.4 ) |> gt::tab_style(style = gt::cell_fill(color ="#eeeeee"),# Light grey backgroundlocations = gt::cells_body(columns =c(S16_pct_3, E8_pct_3, Final4_pct_3, F2_pct_3),rows = year ==2025# Only target 2025 rows ) ) |> gt::tab_options (source_notes.font.size = gt::px(10),row.striping.background_color ='white',column_labels.text_transform ='none' ) |> gt::tab_style(locations = gt::cells_column_labels(),style = gt::cell_text(weight =850, ) ) |> gtUtils::gt_column_subheaders(First4_pct_3 =list(heading ="First 4", subtitle ="3PTM-3PTA"),R64_pct_3 =list(heading ="1st Round", subtitle ="Round of 64"),R32_pct_3 =list(heading ="2nd Round", subtitle ="Round of 32"),S16_pct_3 =list(heading ="Sweet 16", subtitle ="3PTM-3PTA"),E8_pct_3 =list(heading ="Elite 8", subtitle ="3PTM-3PTA"),Final4_pct_3 =list(heading ="Final 4", subtitle ="3PTM-3PTA"),F2_pct_3 =list(heading ="Title Game", subtitle ="3PTM-3PTA"),heading_color ="black",subtitle_color ="gray" ) |> gt::cols_label(year ="Year") |> gt::tab_header(title = gt::md("**NCAA Tournament: 3PT Shooting by Round Since 2011**"),subtitle ="Shows the three-point shooting percentages by round of the NCAA Tournament since 2011." ) |> gt::tab_source_note(source_note = gt::html("NCAA moved back the 3PT line to 22 feet, 1¾ inches at start of 2019-20 season.<br>Data through March 23, 2025 games<hr><br><b>Table by Chris at Bless your chart <br> data via barttorvik.com and @cobrastats</b>" ) ) |> gtUtils::gt_border_grid(color ="black",weight =2,include_labels =FALSE)gtUtils::gt_save_crop( ncaat_shots_tbl,file ="ncaat_shots_tbl.png",whitespace =40,bg ="white" )ncaat_shots_tbl
NCAA Tournament: 3PT Shooting by Round Since 2011
Shows the three-point shooting percentages by round of the NCAA Tournament since 2011.
Year
First 4 3PTM-3PTA
1st Round Round of 64
2nd Round Round of 32
Sweet 16 3PTM-3PTA
Elite 8 3PTM-3PTA
Final 4 3PTM-3PTA
Title Game 3PTM-3PTA
2025
41.3%
83-201
30.9%
504-1633
35.7%
246-689
-
-
-
-
-
-
-
-
2024
31.7%
46-145
35.6%
505-1417
33.6%
250-744
33.9%
124-366
31.2%
55-176
39.1%
36-92
24.1%
7-29
2023
35.5%
61-172
30.9%
410-1326
30.7%
211-687
36.7%
126-343
30.8%
49-159
39.5%
34-86
30.0%
12-40
2022
31.8%
50-157
34.2%
459-1342
29.1%
199-684
29.1%
101-347
23.6%
34-144
39.8%
41-103
27.5%
11-40
2021
30.7%
50-163
33.8%
461-1364
36.4%
262-719
27.2%
91-334
33.6%
45-134
39.5%
32-81
37.5%
15-40
2019
39.9%
71-178
33.5%
507-1512
34.7%
257-740
33.9%
131-386
33.3%
64-192
33.0%
32-97
38.9%
21-54
2018
28.0%
51-182
33.2%
467-1405
34.4%
249-724
34.0%
109-321
27.1%
52-192
33.3%
33-99
26.0%
13-50
2017
34.2%
52-152
35.1%
466-1328
34.3%
220-641
36.7%
128-349
30.6%
49-160
36.0%
31-86
26.1%
12-46
2016
27.8%
47-169
34.2%
429-1256
33.0%
221-670
38.3%
120-313
34.2%
53-155
33.3%
29-87
61.3%
19-31
2015
35.0%
57-163
35.3%
422-1195
37.6%
207-550
29.7%
81-273
41.3%
45-109
36.5%
19-52
34.4%
11-32
2014
28.1%
39-139
33.3%
362-1087
34.9%
206-591
33.3%
89-267
38.0%
54-142
34.0%
16-47
31.4%
11-35
2013
40.7%
59-145
31.6%
372-1177
34.5%
209-606
34.9%
84-241
27.1%
39-144
31.3%
26-83
47.1%
16-34
2012
25.7%
35-136
33.7%
378-1123
33.2%
208-626
34.0%
107-315
31.9%
38-119
33.3%
17-51
44.0%
11-25
2011
32.7%
50-153
34.3%
417-1216
38.8%
214-551
33.2%
113-340
29.6%
50-169
31.0%
26-84
22.7%
10-44
NCAA moved back the 3PT line to 22 feet, 1¾ inches at start of 2019-20 season.
Data through March 23, 2025 games
Table by Chris at Bless your chart
data via barttorvik.com and @cobrastats