gt (version 0.8.0)

tab_stubhead: Add label text to the stubhead

Description

Add a label to the stubhead of a gt table. The stubhead is the lone element that is positioned left of the column labels, and above the stub. If a stub does not exist, then there is no stubhead (so no change will be made when using this function in that case). We have the flexibility to use Markdown formatting for the stubhead label. Furthermore, if the table is intended for HTML output, we can use HTML for the stubhead label.

Usage

tab_stubhead(data, label)

Value

An object of class gt_tbl.

Arguments

data

A table object that is created using the gt() function.

label

The text to be used as the stubhead label We can optionally use the md() and html() functions to style the text as Markdown or to retain HTML elements in the text.

Examples

Use gtcars to create a gt table. With tab_stubhead() we can add a stubhead label. This appears in the top-left and can be used to describe what is in the stub.

gtcars %>%
  dplyr::select(model, year, hp, trq) %>%
  dplyr::slice(1:5) %>%
  gt(rowname_col = "model") %>%
  tab_stubhead(label = "car")

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

Function ID

2-5

See Also

Other part creation/modification functions: tab_caption(), tab_footnote(), tab_header(), tab_info(), tab_options(), tab_row_group(), tab_source_note(), tab_spanner_delim(), tab_spanner(), tab_stub_indent(), tab_style_body(), tab_style()