The cells_row_groups() function

Let’s use a summarized version of the pizzaplace dataset to create a gt table with grouped data. Add a summary with summary_rows() and then add a footnote to the "peppr_salami" row group label with tab_footnote(); the targeting is done with cells_row_groups() in the locations argument.

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.