cells_stubhead: Location helper for targeting the table stubhead cell

View source: R/helpers.R

cells_stubheadR Documentation

Location helper for targeting the table stubhead cell

Description

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-13

Function Introduced

v0.2.0.5 (March 31, 2020)

See Also

Other location helper functions: cells_body(), cells_column_labels(), cells_column_spanners(), cells_footnotes(), cells_grand_summary(), cells_row_groups(), cells_source_notes(), cells_stub(), cells_stub_grand_summary(), cells_stub_summary(), cells_summary(), cells_title(), location-helper


gt documentation built on Sept. 11, 2024, 5:15 p.m.