Skip to contents

cells_stubhead() is used to target the table stubhead location when applying a footnote with tab_footnote() or adding custom style with tab_style(). The function is expressly used in each of those functions' locations argument. The 'stubhead' location is always present alongside the 'stub' location.

Usage

cells_stubhead()

Value

A list object with the classes cells_stubhead and location_cells.

Examples

Using a summarized version of the pizzaplace dataset, let's create a gt table. Add a stubhead label with tab_stubhead() and then style it with tab_style() in conjunction with the use of cells_stubhead() in the locations argument.

pizzaplace |>
  dplyr::mutate(month = as.numeric(substr(date, 6, 7))) |>
  dplyr::group_by(month, type) |>
  dplyr::summarize(sold = dplyr::n(), .groups = "drop") |>
  dplyr::filter(month %in% 1:2) |>
  gt(rowname_col = "type") |>
  tab_stubhead(label = "type") |>
  tab_style(
    style = cell_fill(color = "lightblue"),
    locations = cells_stubhead()
  )

This image of a table was generated from the first code example in the `cells_stubhead()` help file.

Function ID

8-12

Function Introduced

v0.2.0.5 (March 31, 2020)