Understand what's been set inside of a gt table objectSource:
It can become increasingly difficult to recall the ID values associated with
different labels in a gt table. Further to this, there are also
situations where gt will generate ID values on your behalf (e.g., with
tab_spanner_delim(), etc.) while ensuring that duplicate ID values aren't
produced. For the latter case, it is impossible to know what those ID values
are unless one were to carefully examine to correct component of the
Because it's so essential to know these ID values for targeting purposes
(when styling with
tab_style(), adding footnote marks with
tab_footnote(), etc.), the
tab_info() function can help with all of this.
It summarizes (by location) all of the table's ID values and their associated
labels. The product is an informational gt table, designed for easy
retrieval of the necessary values.
A table object that is created using the
gtcars to create a gt table. Use the
tab_spanner() function to
group two columns together under a spanner column with the ID and label
"performance". Finally, use the
tab_info() function to get a table that
summarizes the ID values and their 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()
Other part creation/modification functions: