View source: R/tab_create_modify.R
tab_stubhead | R Documentation |
We can add a label to the stubhead of a gt table with the
tab_stubhead()
function. The stubhead is the lone part of the table 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 visible change will be made when
using this function in that case). We have the flexibility to use Markdown
formatting for the stubhead label via the md()
helper function.
Furthermore, if the table is intended for HTML output, we can use HTML inside
of html()
for the stubhead label.
tab_stubhead(data, label)
data |
The gt table data object
This is the gt table object that is commonly created through use of the
|
label |
Stubhead label text
The text to be used as the stubhead label. We can optionally use the |
An object of class gt_tbl
.
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 the tab_stubhead()
function to
describe what's in the stub.
gtcars |> dplyr::select(model, year, hp, trq) |> dplyr::slice(1:5) |> gt(rowname_col = "model") |> tab_stubhead(label = "car")
The stuhead 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.
gtcars |> dplyr::select(model, year, hp, trq) |> dplyr::slice(1:5) |> gt(rowname_col = "model") |> tab_stubhead(label = fontawesome::fa("car"))
2-5
v0.2.0.5
(March 31, 2020)
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()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.