Use a subset of the gtcars dataset to create a gt table. tab_source_note() is used to add a source note to the table footer that cites the data source (or, it could just be arbitrary text). We’ll use the function twice, in effect adding two source notes to the footer.
gt_tbl <- gtcars |> dplyr::select(mfr, model, msrp) |> dplyr::slice(1:5) |>gt() |>tab_source_note(source_note ="Data from the 'edmunds.com' site.") |>tab_source_note(source_note ="Showing only the first five rows.") |>cols_width(everything() ~px(120))gt_tbl
mfr
model
msrp
Ford
GT
447000
Ferrari
458 Speciale
291744
Ferrari
458 Spider
263553
Ferrari
458 Italia
233509
Ferrari
488 GTB
245400
Data from the 'edmunds.com' site.
Showing only the first five rows.
If you decide that you don’t want the source notes in the gt_tbl object, they can be removed with rm_source_notes().
rm_source_notes(data = gt_tbl)
mfr
model
msrp
Ford
GT
447000
Ferrari
458 Speciale
291744
Ferrari
458 Spider
263553
Ferrari
458 Italia
233509
Ferrari
488 GTB
245400
Individual source notes can be selectively removed. Source notes are identified by their index values. To remove the source note concerning the extent of the data (source note 2, since it was supplied to gt after the other source note) we would give the correct index value to source_notes.