Using a small subset of the gtcars dataset, we can create a gt table with row labels. Since we have row labels in the stub (via use of rowname_col = "model" in the gt() function call) we have a stubhead, so, let’s add a stubhead label ("car") with tab_stubhead() to describe what’s in the stub.
The stubhead can contain all sorts of interesting content. How about an icon for a car? We can make this happen with help from the fontawesome package.
If the stub is two columns wide (made possible by using row_group_as_column = TRUE in the gt() statement), the stubhead will be a merged cell atop those two stub columns representing the row group and the row label. Here’s an example of that type of situation in a table that uses the peeps dataset.
The stubhead cell and its text can be styled using tab_style() with cells_stubhead(). In this example, using the reactions dataset, we style the stubhead label so that it is vertically centered with text that is highly emboldened.