fmts | R Documentation |
All formatting functions in gt are quite consistent. All functions that start
with the common fmt_*()
prefix have the following points in common
Let's use the exibble data for this.
gt_tbl <- gt(exibble)
#
# They all have `columns` and `rows` to specify target cells and default to
# styling all compatible cells.
#
# By default, they apply styling to all compatible columns.
# Will style all numeric columns
gt_tbl %>% fmt_number()
# will style the time column
gt_tbl %>% fmt_time(columns = time)
# Will style nothing since is only compatible with logical values
gt_tbl %>% fmt_tf()
#
# Their order has importance as the last styling will have priority.
#
# Will style all numeric columns as integer
# fmt_number() will have no effect
gt_tbl %>% fmt_number() %>% fmt_integer()
#
# Therefore, to apply different styling, it is important to specify columns or rows.
#
# Will style all numeric columns as number and as currency the currency column.
# fmt_number() will have no effect
gt_tbl %>% fmt_number() %>% fmt_integer(currency)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.