With numeric values in a gt table we can transform those to Roman numerals, rounding values as necessary.
fmt_roman(
data,
columns,
rows = everything(),
case = c("upper", "lower"),
pattern = "{x}"
)
An object of class gt_tbl
.
A table object that is created using the gt()
function.
The columns to format. Can either be a series of column names
provided in c()
, a vector of column indices, or a helper function
focused on selections. The select helper functions are: starts_with()
,
ends_with()
, contains()
, matches()
, one_of()
, num_range()
, and
everything()
.
Optional rows to format. Providing everything()
(the
default) results in all rows in columns
being formatted. Alternatively,
we can supply a vector of row captions within c()
, a vector of row
indices, or a helper function focused on selections. The select helper
functions are: starts_with()
, ends_with()
, contains()
, matches()
,
one_of()
, num_range()
, and everything()
. We can also use expressions
to filter down to the rows we need (e.g.,
[colname_1] > 100 & [colname_2] < 50
).
Should Roman numerals should be rendered as uppercase ("upper"
)
or lowercase ("lower"
) letters? By default, this is set to "upper"
.
A formatting pattern that allows for decoration of the
formatted value. The value itself is represented by {x}
and all other
characters are taken to be string literals.
Targeting of values is done through columns
and additionally by rows
(if
nothing is provided for rows
then entire columns are selected). Conditional
formatting is possible by providing a conditional expression to the rows
argument. See the Arguments section for more information on this.
Create a tibble of small numeric values and generate a gt table. Format
the roman
column to appear as Roman numerals with fmt_roman()
.
dplyr::tibble(arabic = c(1, 8, 24, 85), roman = arabic) %>%
gt(rowname_col = "arabic") %>%
fmt_roman(columns = roman)
3-9
Other data formatting functions:
data_color()
,
fmt_bytes()
,
fmt_currency()
,
fmt_datetime()
,
fmt_date()
,
fmt_duration()
,
fmt_engineering()
,
fmt_fraction()
,
fmt_integer()
,
fmt_markdown()
,
fmt_number()
,
fmt_partsper()
,
fmt_passthrough()
,
fmt_percent()
,
fmt_scientific()
,
fmt_time()
,
fmt()
,
sub_large_vals()
,
sub_missing()
,
sub_small_vals()
,
sub_values()
,
sub_zero()
,
text_transform()