opt_all_caps: Option to use all caps in select table locations

View source: R/opts.R

opt_all_capsR Documentation

Option to use all caps in select table locations


Sometimes an all-capitalized look is suitable for a table. With the opt_all_caps() function, we can transform characters in the column labels, the stub, and in all row groups in this way (and there's control over which of these locations are transformed).

This function serves as a convenient shortcut for ⁠<gt_tbl> |> tab_options(<location>.text_transform = "uppercase", <location>.font.size = pct(80), <location>.font.weight = "bolder")⁠ (for all locations selected).


  all_caps = TRUE,
  locations = c("column_labels", "stub", "row_group")



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.


Use all-caps transformation

⁠scalar<logical>⁠ // default: TRUE

A logical value to indicate whether the text transformation to all caps should be performed (TRUE, the default) or reset to default values (FALSE) for the locations targeted.


Locations to target

⁠mult-kw:[column_labels|stub|row_group]⁠ // default: c("column_labels", "stub", "row_group")

Which locations should undergo this text transformation? By default it includes all of the "column_labels", the "stub", and the "row_group" locations. However, we could just choose one or two of those.


An object of class gt_tbl.


Use the exibble dataset to create a gt table with a number of table parts added (using functions like summary_rows(), grand_summary_rows(), and more). Following that, we'll ensure that all text in the column labels, the stub, and in all row groups is transformed to all caps using opt_all_caps().

exibble |>
  gt(rowname_col = "row", groupname_col = "group") |>
    groups = "grp_a",
    columns = c(num, currency),
    fns = c("min", "max")
  ) |>
    columns = currency,
    fns = total ~ sum(., na.rm = TRUE)
  ) |>
  tab_source_note(source_note = "This is a source note.") |>
    footnote = "This is a footnote.",
    locations = cells_body(columns = 1, rows = 1)
  ) |>
    title = "The title of the table",
    subtitle = "The table's subtitle"
  ) |>
This image of a table was generated from the first code example in the `opt_all_caps()` help file.

Function ID


Function Introduced

v0.2.0.5 (March 31, 2020)

See Also

Other table option functions: opt_align_table_header(), 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()

gt documentation built on Oct. 7, 2023, 9:07 a.m.