rm_footnotes: Remove table footnotes

View source: R/tab_remove.R

rm_footnotesR Documentation

Remove table footnotes


If you have one or more footnotes that ought to be removed, the rm_footnotes() 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 footnotes and source notes.

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 footnotes be removed. This function is safe to use even if there are no footnotes in the input gt_tbl object so long as select helpers (such as the default everything()) are used instead of explicit integer values.


rm_footnotes(data, footnotes = everything())



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.


Footnotes to remove

⁠scalar<numeric|integer>|everything()⁠ // default: everything()

A specification of which footnotes should be removed. The footnotes 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 footnotes will be removed).


An object of class gt_tbl.


Use a subset of the sza dataset to create a gt table. Color the sza column using the data_color() function, then, use tab_footnote() twice to add two footnotes (each one targeting a different column label).

gt_tbl <-
  sza |>
    latitude == 20 &
      month == "jan" &
  ) |>
  dplyr::select(-latitude, -month) |>
  gt() |>
    columns = sza,
    palette = c("white", "yellow", "navyblue"),
    domain = c(0, 90)
  ) |>
    footnote = "Color indicates height of sun.",
    locations = cells_column_labels(
      columns = sza
  ) |>
    footnote = "
    The true solar time at the given latitude
    and date (first of month) for which the
    solar zenith angle is calculated.
    locations = cells_column_labels(
      columns = tst
  ) |>
  cols_width(everything() ~ px(150))

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

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

rm_footnotes(data = gt_tbl)
This image of a table was generated from the second code example in the `rm_footnotes()` help file.

Individual footnotes can be selectively removed. Footnotes are identified by their index values. To remove the footnote concerning true solar time (footnote 2, since it was supplied to gt after the other footnote) we would give the correct index value to footnotes.

rm_footnotes(data = gt_tbl, footnotes = 2)
This image of a table was generated from the third code example in the `rm_footnotes()` help file.

Function ID


Function Introduced

v0.8.0 (November 16, 2022)

See Also

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

gt documentation built on June 22, 2024, 11:11 a.m.