013: ACC Refs

gt tables
bar chart
Published

January 26, 2023

Load data and manipulate

Code
# load data scraped from kp to find official ids
# kp_data <- read_csv("data.csv")

# find ids
# ids <- kp_data$ref_id

# loop function 
# add_fun <- function(id) {
#   kp_referee(referee = id, year = 2023)
# }

# save refs - this is terribly inefficient 
# refs <- lapply(ids, add_fun)

# make dataframe and filter down to acc
# acc_refs <- as.data.frame(do.call(rbind, refs)) %>%
#           filter(conference == "ACC")

acc_refs <- read_csv("acc_refs_jan_26.csv")

full <- acc_refs %>%
            add_row(referee_name ="Jenna Reneau", thrill_score = 12.5) %>%
            add_row(referee_name ="Courtney Smith", thrill_score = 50.4) %>%
            group_by(referee_name) %>%
            summarize(avg_t = mean(thrill_score),
            count = n()) %>%
            arrange(count)

# get full rankings
ranks <- kp_officials(year = most_recent_mbb_season()) %>%
         rename(referee_name = official_name)

# combine with previous table 
acc_rks <- merge(ranks, full, by = "referee_name") %>%
           select(referee_name, rk, ref_rating, gms, avg_t, count) %>%
           arrange(rk)

Set the themes for the plot

Code
# theme
  theme_me <- function () {
    theme_minimal(base_size = 10, base_family = "RobotoCondensed-Regular") %+replace%
      theme (
        plot.title = element_text(
          hjust = 0.5,
          size = 24,
          face = "bold"
        ),
        plot.subtitle = element_text(
          hjust = 0.5,
          size = 10,
          lineheight = 0.25,
          vjust = -0.5
        ),
        plot.caption = element_text(
          hjust = 1,
          size = 6,
          lineheight = 0.35,
          margin = margin(t = 20)
        ),
        panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "floral white", color = "floral white")
      )
  }

Make the bar plot

Code
ref_plot <- full %>%
  mutate(referee_name = factor(referee_name, levels = .$referee_name)) %>%
  mutate(color = case_when(count > 9 ~ "#e9a3c9",
                           count > 4 ~ "#a1d76a",
                           ## all others should be gray
                           TRUE ~ "#acacac")) %>%
  ggplot(aes(count, referee_name, fill = color)) +
  geom_col() +
  scale_x_continuous(breaks = seq(0, 14, 1), limits = c(0, 14)) +
  labs(
    x = "Games",
    y = "",
    title = "<span style='color:#333333;'>Who are the *referees* on the court for ACC games? </span>",
    caption = "dadgumboxscores | January 26, 2023 | data via kenpom"
  ) +
  theme_me() +
  scale_fill_identity(guide = "none") +
  theme(plot.title = element_textbox_simple()) +
  annotate(
    "text",
    x = 12.8,
    y = 35,
    label = "10 or  \n more games",
    family = "Chalkboard Bold",
    size = 4,
    fontface = "bold",
    color = "#e9a3c9",
  ) +
  annotate(
    "text",
    x = 9,
    y = 29,
    label = "5 or  \nmore games",
    family = "Chalkboard Bold",
    size = 4,
    fontface = "bold",
    color = "#a1d76a",
  ) +
  annotate(
    "text",
    x = 5,
    y = 13,
    label = "Fewer than \n5 games",
    family = "Chalkboard Bold",
    size = 4,
    color = "#acacac",
    fontface = "bold",
  )

# save it
ggsave(
  "ref.png",
  ref_plot,
  w = 6.5,
  h = 8,
  dpi = 300,
  type = 'cairo'
)


ref_plot

Make the ref tables

Code
table <- acc_rks %>%
  gt() %>%
  cols_label(
    # rename columns
    referee_name = "Ref",
    rk = "Rank",
    ref_rating = "Rating",
    gms = "G",
    avg_t = "Rating",
    count = "G"
  ) %>%
  tab_spanner(label = "ACC only",
              columns = c(avg_t, count)) %>%
  tab_spanner(label = "All Games",
              columns = c(rk, ref_rating)) %>%
  fmt_number(columns = avg_t,
             decimals = 2,
             use_seps = FALSE) %>%
  gt_theme_dot_matrix() %>%
  tab_header(title = md("Ref ratings from kenpom with #goacc refs")) %>%
  tab_source_note(source_note = "@dadgumboxscores | January 19, 2023 | data via kenpom") %>%
  tab_options (
    source_notes.font.size = px(10),
    row.striping.background_color = '#ffffed',
    table.font.size = px(10),
    column_labels.text_transform = 'capitalize'
  )

gtsave_extra(table,
             "ref_table.png",
             vwidth = 650,
             vheight = 650)

table
Ref ratings from kenpom with #goacc refs
Ref All Games G ACC only
Rank Rating Rating G
Keith Kimble 1 54.79 62 61.67 3
Doug Sirmons 2 52.58 62 42.68 6
Kipp Kissinger 4 49.57 61 42.66 5
Roger Ayers 5 49.57 60 47.52 13
Paul Szelc 6 48.36 48 50.30 1
Bert Smith 7 47.59 58 47.89 14
Ron Groover 8 46.80 60 47.27 12
Terry Oglesby 10 46.20 54 66.70 1
Lee Cassell 12 44.94 54 51.31 10
Mike Roberts 16 42.61 47 58.93 3
John Gaffney 18 41.55 57 49.89 7
Doug Shows 19 41.03 47 53.04 5
Jeffrey Anderson 20 40.86 47 42.83 7
Brian O'Connell 22 40.46 53 55.00 7
Brent Hampton 26 38.95 47 37.02 5
Pat Driscoll 27 38.26 49 41.92 6
Tony Chiazza 28 37.74 51 63.60 1
Clarence Armstrong 31 36.11 53 43.09 12
Jeff Clark 32 35.66 49 54.43 3
Earl Walton 37 33.89 51 39.70 1
Matt Potter 38 33.67 55 41.96 7
Jeb Hartness 42 33.09 50 35.20 3
Lamar Simpson 44 31.89 49 30.63 3
Jamie Luckie 45 31.88 42 47.95 6
Tommy Morrissey 46 31.80 46 51.34 12
Bill Covington Jr. 48 30.94 43 47.77 10
Greg Evans 58 28.73 43 62.40 1
A.J. Desai 61 27.99 46 49.13 6
Ted Valentine 66 27.52 43 47.86 14
Tim Clougherty 71 26.59 40 43.77 7
Tony Henderson 74 26.41 37 52.40 7
Chance Moore 80 24.64 40 31.90 1
Jerry Heater 91 22.06 37 39.05 2
Justin Porterfield 94 21.26 34 41.38 4
Mark Schnur 97 20.87 34 44.90 2
Jeff Pon 103 19.31 28 49.65 2
Trey Styons 118 17.81 28 43.50 1
Raymond Styons 122 16.72 30 38.08 4
Jemel Spearman 129 15.35 28 39.60 3
@dadgumboxscores | January 19, 2023 | data via kenpom