065: PPP Table

gt_table
Published

January 2, 2024

Data

Code
## first ppp under 1
cbbdata::cbd_torvik_game_stats(team = "North Carolina") -> unc_facts

unc_ppp <- unc_facts |> 
  dplyr::arrange(date) |> 
  dplyr::group_by(year) |> 
  dplyr::mutate(games = dplyr::n(),
                season_game_no = dplyr::row_number()) |>  # Number within each season
  dplyr::filter(off_ppp < 100) |> 
  dplyr::slice(1) |> 
  dplyr::select(date, games, year, type, opp, result, off_ppp, season_game_no, pts, opp_pts) |> 
  dplyr::mutate(score = paste0(result, ",", "", pts, "-", opp_pts),
                game = season_game_no,
                off_ppp = off_ppp/100) |> 
  dplyr::select(year, date, opp, score, off_ppp, game, games, season_game_no) |> 
  dplyr::ungroup() |> 
  dplyr::add_row(year = 2009, opp = "Not found!", date = as.Date("2009-04-06"), game = 38, games = 38, season_game_no = 38,
                 score = "All games over 1 PPP") |> 
  dplyr::add_row(year = 2024, opp = "Not found!", date = as.Date("2024-01-02"), game = 13, games = 13, season_game_no = 13,
                 score = "All games over 1 PPP") |> 
  dplyr::arrange(-year) |> 
  dplyr::mutate(dplyr::across(everything(), ~ replace(.x, is.na(.x), ""))) |> 
  dplyr::mutate(game = as.numeric(game),
                games = as.numeric(games), 
                season_game_no = as.numeric(season_game_no))

GT Table

Code
unc_ppp |> 
  dplyr::mutate(date = format(as.Date(date), "%b. %d, %Y")) |> 
  gt::gt() |> 
  gt::cols_label(year = "Season", 
                 date = "Date", 
                 opp = "Opponent", 
                 score = "Result",
                 off_ppp = "PPP",
                 game = "Game #", 
                 games = "") |> 
  gt::data_color(columns = c(game),
                 colors = scales::col_numeric(
                   c(
                     "#ffb6c1",
                     "#fff1f3",
                     "#d2f8d2",
                     "#b0f3b0"
                   ),
                   domain = c(1, 38)
                 )) |>
  gtExtras::gt_highlight_rows(
    rows = c(1, 16),
    fill = "#d0e4f3",
    bold_target_only = TRUE,
    target_col = c(score),
  ) |> 
  gtExtras::gt_plt_bullet(column = games, target = season_game_no, width = 45,
                          palette = c("#56a0d3", "black")) |> 
  cbbdata::gt_theme_athletic() |> 
  gt::tab_header(title = "North Carolina: Number of games before scoring  \n
                 under 1 point per possession in a game each season since 2008", 
                 subtitle = "Carolina has yet to score under 1 point per possession through 13 games of the 2024 season.") |> 
  gt::tab_source_note(source_note = "Bless your chart | data via cbbdata | January 2, 2024")  -> ppp_tbl 

gtExtras::gtsave_extra(ppp_tbl, filename = "ppp_table.png", vheight = 975, vwidth = 900)

ppp_tbl
North Carolina: Number of games before scoring under 1 point per possession in a game each season since 2008
Carolina has yet to score under 1 point per possession through 13 games of the 2024 season.
Season Date Opponent Result PPP Game #
2024 Jan. 02, 2024 Not found! All games over 1 PPP 13
2023 Nov. 27, 2022 Alabama L,101-103 0.998 7
2022 Nov. 21, 2021 Tennessee L,72-89 0.974 5
2021 Dec. 01, 2020 Stanford W,67-63 0.945 3
2020 Nov. 27, 2019 Alabama W,76-67 0.973 5
2019 Nov. 28, 2018 Michigan L,67-84 0.963 8
2018 Nov. 26, 2017 Michigan St. L,45-63 0.623 6
2017 Nov. 30, 2016 Indiana L,67-76 0.935 7
2016 Feb. 01, 2016 Louisville L,65-71 0.917 22
2015 Nov. 26, 2014 Butler L,66-74 0.863 4
2014 Nov. 15, 2013 Holy Cross W,62-54 0.88 2
2013 Nov. 20, 2012 Butler L,71-82 0.982 5
2012 Nov. 11, 2011 Michigan St. W,67-55 0.977 1
2011 Nov. 19, 2010 Minnesota L,67-72 0.872 3
2010 Nov. 20, 2009 Syracuse L,71-87 0.934 5
2009 Apr. 06, 2009 Not found! All games over 1 PPP 38
2008 Nov. 14, 2007 Davidson W,72-68 0.921 1
Bless your chart | data via cbbdata | January 2, 2024