The tab_info() function

Let’s use a portion of the gtcars dataset to create a gt table. We’ll use tab_spanner() to group two columns together under a spanner column with the ID and label "performance". Finally, we can usetab_info() in a separate, interactive statement so that we can inspect a table that summarizes the ID values any associated label text for all parts of the table.

gt_tbl <-
  gtcars |>
  dplyr::select(model, year, starts_with("hp"), msrp) |>
  dplyr::slice(1:4) |>
  gt(rowname_col = "model") |>
  tab_spanner(
    label = "performance",
    columns = starts_with("hp")
  )

gt_tbl |> tab_info()
Information on ID and Label Values
ID Idx
Lvl
Label
Columns
model 1 model
year 2 year
hp 3 hp
hp_rpm 4 hp_rpm
msrp 5 msrp
Rows
GT 1 GT
458 Speciale 2 458 Speciale
458 Spider 3 458 Spider
458 Italia 4 458 Italia
Spanners
performance 1 performance