tab_source_note: Add a source note citation

View source: R/tab_create_modify.R

tab_source_noteR Documentation

Add a source note citation

Description

Add a source note to the footer part of the gt table. A source note is useful for citing the data included in the table. Several can be added to the footer, simply use multiple calls of tab_source_note() and they will be inserted in the order provided. We can use Markdown formatting for the note, or, if the table is intended for HTML output, we can include HTML formatting.

Usage

tab_source_note(data, source_note)

Arguments

data

The gt table data object

⁠obj:<gt_tbl>⁠ // required

This is the gt table object that is commonly created through use of the gt() function.

source_note

Source note text

⁠scalar<character>⁠ // required

Text to be used in the source note. We can optionally use md() and html() to style the text as Markdown or to retain HTML elements in the text.

Value

An object of class gt_tbl.

Examples

With three columns from the gtcars dataset, let's create a gt table. We can use tab_source_note() to add a source note to the table footer. Here we are citing the data source but this function can be used for any text you'd prefer to display in the footer section.

gtcars |>
  dplyr::select(mfr, model, msrp) |>
  dplyr::slice(1:5) |>
  gt() |>
  tab_source_note(source_note = "From edmunds.com")
This image of a table was generated from the first code example in the `tab_source_note()` help file.

Function ID

2-8

Function Introduced

v0.2.0.5 (March 31, 2020)

See Also

Other part creation/modification functions: tab_caption(), tab_footnote(), tab_header(), tab_info(), tab_options(), tab_row_group(), tab_spanner(), tab_spanner_delim(), tab_stub_indent(), tab_stubhead(), tab_style(), tab_style_body()


rstudio/gt documentation built on Nov. 2, 2024, 5:53 p.m.