View source: R/tab_create_modify.R
tab_caption | R Documentation |
Add a caption to a gt table, which is handled specially for a table within an R Markdown, Quarto, or bookdown context. The addition of captions makes tables cross-referencing across the containing document. The caption location (i.e., top, bottom, margin) is handled at the document level in each of these systems.
tab_caption(data, caption)
data |
The gt table data object
This is the gt table object that is commonly created through use of the
|
caption |
Table caption text
The table caption to use for cross-referencing in R Markdown, Quarto, or bookdown. |
An object of class gt_tbl
.
With three columns from the gtcars
dataset, let's create a gt table.
First, we'll add a header part with tab_header()
. After that, a caption is
added with tab_caption()
.
gtcars |> dplyr::select(mfr, model, msrp) |> dplyr::slice(1:5) |> gt() |> tab_header( title = md("Data listing from **gtcars**"), subtitle = md("`gtcars` is an R dataset") ) |> tab_caption(caption = md("**gt** table example."))
2-9
v0.8.0
(November 16, 2022)
Other part creation/modification functions:
tab_footnote()
,
tab_header()
,
tab_info()
,
tab_options()
,
tab_row_group()
,
tab_source_note()
,
tab_spanner()
,
tab_spanner_delim()
,
tab_stub_indent()
,
tab_stubhead()
,
tab_style()
,
tab_style_body()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.