# Function to update conference abbreviations to be more friendly
conf_name_lookup <- function(conf_var) {
conf_var = dplyr::case_match(
conf_var,
"B12" ~ "Big 12",
"BE" ~ "Big East",
"P12" ~ "Pac-12",
"B10" ~ "Big Ten",
"Amer" ~ "American",
"SB" ~ "Sun Belt",
"Slnd" ~ "Southland",
"BW" ~ "Big West",
"SC" ~ "Southern",
"AE" ~ "America East",
"BSth" ~ "Big South",
"ASun" ~ "Atlantic Sun",
"Pat" ~ "Patriot",
"Horz" ~ "Horizon",
"BSky" ~ "Big Sky",
"OVC" ~ "Ohio Valley",
"Sum" ~ "Summit",
"A10" ~ "Atlantic 10",
"MWC" ~ "Mountain West",
"MVC" ~ "Missouri Valley",
"NEC" ~ "Northeast",
"MAC" ~ "Mid-American",
"MAAC" ~ "Metro Atlantic",
"ind" ~ "Independent",
conf_var ~ conf_var
)
}
# Grab conference records
conf_data <-
cbbdata::cbd_torvik_game_stats(year = 2024, type = "conf")
net_up <-
cbbdata::cbd_all_metrics() |>
dplyr::mutate(
conf = dplyr::case_match(
team,
"Tarleton St." ~ "WAC",
"Utah Tech" ~ "WAC",
"St. Thomas" ~ "Sum",
"UC San Diego" ~ "BW",
"Bellarmine" ~ "ASun",
"Queens" ~ "ASun",
"Le Moyne" ~ "NEC",
"Lindenwood" ~ "OVC",
"Texas A&M Commerce" ~ "Slnd",
"Southern Indiana" ~ "OVC",
"Stonehill" ~ "NEC",
team ~ conf
)
) |>
dplyr::mutate(conf = conf_name_lookup(conf))
team_net <- net_up |>
dplyr::select(team, net = net_rank, conf)
conf_records <- conf_data |>
cbbdata::cbd_add_net_quad() |>
dplyr::mutate(delta = abs(pts_scored - opp_pts)) |>
dplyr::select(-net,-conf) |> # drop these for easier joining
dplyr::left_join(team_net, by = "team") |>
dplyr::group_by(conf) |>
dplyr::summarise(
games_played = dplyr::n(),
avg_net = mean(unique(net)),
home_wins = sum(result == "W" & location == "H"),
home_loss = sum(result == "L" & location == "H"),
home_win_pct = (home_wins / (home_wins + home_loss)),
avg_diff = mean(delta),
q1 = sum(quad == "Quadrant 1") / games_played,
q2 = sum(quad == "Quadrant 2") / games_played,
q3 = sum(quad == "Quadrant 3") / games_played,
q4 = sum(quad == "Quadrant 4") / games_played,
) |>
dplyr::arrange(avg_net)
# Grab non-conference records
non_con_data <-
cbbdata::cbd_torvik_game_stats(year = 2024, type = "nc")
non_con_records <- non_con_data |>
dplyr::filter(conf != "ind") |>
cbbdata::cbd_add_net_quad() |>
dplyr::select(-net,-conf) |> # drop these for easier joining
dplyr::left_join(team_net, by = "team") |>
dplyr::group_by(conf) |>
dplyr::summarise(
games_played = dplyr::n(),
avg_net = mean(unique(net)),
q1_rec = paste0(sum(quad == "Quadrant 1" & result == "W"), "-",
sum(quad == "Quadrant 1" & result == "L")),
q1 = sum(quad == "Quadrant 1") / games_played,
q2_rec = paste0(sum(quad == "Quadrant 2" & result == "W"), "-",
sum(quad == "Quadrant 2" & result == "L")),
q2 = sum(quad == "Quadrant 2") / games_played,
q3_rec = paste0(sum(quad == "Quadrant 3" & result == "W"), "-",
sum(quad == "Quadrant 3" & result == "L")),
q3 = sum(quad == "Quadrant 3") / games_played,
q4_rec = paste0(sum(quad == "Quadrant 4" & result == "W"), "-",
sum(quad == "Quadrant 4" & result == "L")),
q4 = sum(quad == "Quadrant 4") / games_played,
) |>
dplyr::arrange(avg_net)
real_nc <- non_con_records |>
dplyr::select(conf, nc_q1 = q1, nc_q2 = q2,
nc_q3 = q3, nc_q4 = q4)
quad_table <- conf_records |>
dplyr::select(conf, con_q1 = q1, con_q2 = q2,
con_q3 = q3, con_q4 = q4) |>
dplyr::left_join(real_nc, by = "conf") |>
dplyr::select(conf, con_q1, nc_q1,
con_q2, nc_q2, con_q3, nc_q3,
con_q4, nc_q4)