The rm_stubhead() function

Using the gtcars dataset, we’ll create a gt table. With tab_stubhead(), it’s possible to add a stubhead label. This appears in the top-left and can be used to describe what is in the stub.

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

gt_tbl
car year hp trq
GT 2017 647 550
458 Speciale 2015 597 398
458 Spider 2015 562 398
458 Italia 2014 562 398
488 GTB 2016 661 561

If you decide that you don’t want the stubhead label in the gt_tbl object, it can be removed with rm_stubhead().

rm_stubhead(data = gt_tbl)
year hp trq
GT 2017 647 550
458 Speciale 2015 597 398
458 Spider 2015 562 398
458 Italia 2014 562 398
488 GTB 2016 661 561