Learn R Programming

gt (version 0.8.0)

rm_source_notes: Remove table source notes

Description

If you have one or more source notes that ought to be removed, the rm_source_notes() function allows for such a selective removal. The table footer is an optional table part that is positioned below the table body, containing areas for both the source notes and footnotes.

This function for removal is useful if you have received a gt table (perhaps through an API that returns gt objects) but would prefer that some or all of the source notes be removed. This function is safe to use even if there are no source notes in the input gt_tbl object so long as select helpers (such as the default everything()) are used instead of explicit integer values.

Usage

rm_source_notes(data, source_notes = everything())

Value

An object of class gt_tbl.

Arguments

data

A table object of class gt_tbl.

source_notes

A specification of which source notes should be removed. The source notes to be removed can be given as a vector of integer values (they are stored as integer positions, in order of creation, starting at 1). A select helper can also be used and, by default, this is everything() (whereby all source notes will be removed).

Examples

Use gtcars to create a gt table. Use tab_source_note() to add a source note to the table footer that cites the data source.

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

This image of a table was generated from the first code example in the `rm_source_notes()` help file.

If you decide that you don't want the source notes in the gt_tbl object, they can be removed with the rm_source_notes() function.

rm_source_notes(data = gt_tbl)

This image of a table was generated from the second code example in the `rm_source_notes()` help file.

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.

rm_source_notes(data = gt_tbl, source_notes = 2)

This image of a table was generated from the third code example in the `rm_source_notes()` help file.

Function ID

6-5

See Also

Other part removal functions: rm_caption(), rm_footnotes(), rm_header(), rm_spanners(), rm_stubhead()