009: Football games are too long

gt tables
Published

January 2, 2023

Load data

Code
times <- tibble::tribble(
    ~Opponent,~Hours,~Minutes,
    "Florida A&M",3,24,
    "Appalachian State",4,10,
    "Georgia State",3,31,
    "Notre Dame",3,30,
    "Virginia Tech",3,13,
    "Miami",3,34,
    "Duke",3,35,
    "Pittsburgh",3,40,
    "Virginia",3,20,
    "Wake Forest",3,40,
    "Georgia Tech",3,16,
    "NC State",3,57,
    "Clemson",3,23,
    "Oregon",3,32
)

Manipulate data

Code
times <- times %>% 
         mutate(total_mins = (Hours *60) + Minutes,
                logo = Opponent,
                avg = mean(total_mins)) 

Make the table with bar chart and logos

Code
times_table <- times %>% 
                select(logo, Opponent, Hours, Minutes, total_mins) %>% 
                arrange(-total_mins) %>% 
                gt() %>%
  cols_label(
    # rename columns
    logo = "",
    total_mins = "",
  ) %>% 
                gt_fmt_cfb_logo(columns = "logo") %>%
                gt_plt_bar(column = total_mins, color = "#56a0d3", keep_column = FALSE, width = 35) %>% 
  tab_header(
    title = "Carolina Length of Football Games in 2022") %>%
  tab_source_note(source_note = "@dadgumboxscores | January 2, 2023")  %>%
  # adjust font sizes
  tab_options (source_notes.font.size = px(10),
               table.font.size = px(12),) %>%
  gt_theme_nytimes()

gtsave(times_table, 'times_table.png', vwidth = 600, vheight = 600)

times_table
Carolina Length of Football Games in 2022
Opponent Hours Minutes
Appalachian State 4 10
NC State 3 57
Pittsburgh 3 40
Wake Forest 3 40
Duke 3 35
Miami 3 34
Oregon 3 32
Georgia State 3 31
Notre Dame 3 30
Florida A&M 3 24
Clemson 3 23
Virginia 3 20
Georgia Tech 3 16
Virginia Tech 3 13
@dadgumboxscores | January 2, 2023