We can alter the order in which marked footnotes appear in relation to any unmarked footnotes in the footer section of the table. A single keyword is to be supplied and it will determine whether marked footnotes should appear: (1) before unmarked, (2) after unmarked, or (3) in call order.
Arguments
- data
The gt table data object
obj:<gt_tbl>// requiredThis is the gt table object that is commonly created through use of the
gt()function.- order
Method for ordering footnote marks
scalar<character>// default:"marks_last"A keyword provided here will determine how marked footnotes will be arranged in relation to unmarked footnotes. Use either:
"marks_last","marks_first", or"preserve_order".
Specification of footnote order
The keywords are:
"marks_last": marked footnotes should appear beneath unmarked in the table (default)"marks_first": marked footnotes should appear before unmarked in the table"preserve_order": footnotes will appear in the order they were specified intab_footnote()
Examples
Use a summarized version of the sza dataset to create a gt table,
adding three marked footnotes and one unmarked (with four calls of
tab_footnote()). We can modify the order of footnotes with the
opt_footnote_order() function.
sza |>
dplyr::filter(latitude == 30) |>
dplyr::group_by(tst) |>
dplyr::summarize(
SZA.Max = if (
all(is.na(sza))) {
NA
} else {
max(sza, na.rm = TRUE)
},
SZA.Min = if (
all(is.na(sza))) {
NA
} else {
min(sza, na.rm = TRUE)
},
.groups = "drop"
) |>
gt(rowname_col = "tst") |>
tab_spanner_delim(delim = ".") |>
sub_missing(
columns = everything(),
missing_text = "90+"
) |>
tab_stubhead(label = "TST") |>
tab_footnote(
footnote = "True solar time.",
locations = cells_stubhead()
) |>
tab_footnote(
footnote = "Solar zenith angle.",
locations = cells_column_spanners(
spanners = "spanner-SZA.Max"
)
) |>
tab_footnote(
footnote = "The Lowest SZA.",
locations = cells_stub(rows = "1200")
) |>
tab_footnote(
footnote = "Values calculated on the first of every month."
) |>
opt_footnote_order(order = "marks_first")
See also
Other table option functions:
opt_align_table_header(),
opt_all_caps(),
opt_css(),
opt_footnote_marks(),
opt_footnote_spec(),
opt_horizontal_padding(),
opt_interactive(),
opt_row_striping(),
opt_stylize(),
opt_table_font(),
opt_table_lines(),
opt_table_outline(),
opt_vertical_padding()