The cells_row_groups() function

Use pizzaplace to create a gt table with grouped data. Add a summary with the summary_rows() function and then add a footnote to the "peppr_salami" row group label with tab_footnote() and with cells_row_groups() in locations.

pizzaplace |>
  dplyr::filter(name %in% c("soppressata", "peppr_salami")) |>
  dplyr::group_by(name, size) |>
  dplyr::summarize(`Pizzas Sold` = dplyr::n(), .groups = "drop") |>
  gt(rowname_col = "size", groupname_col = "name") |>
  summary_rows(
    columns = `Pizzas Sold`,
    fns = list(label = "TOTAL", fn = "sum"),
    fmt = ~ fmt_integer(.)
  ) |>
  tab_footnote(
    footnote = "The Pepper-Salami.",
    cells_row_groups(groups = "peppr_salami")
  )
Pizzas Sold
peppr_salami1
L 696
M 428
S 322
TOTAL 1,446
soppressata
L 405
M 268
S 288
TOTAL 961
1 The Pepper-Salami.