Format by passing data through no other transformation other than: (1)
coercing to character
(as all the fmt_*()
functions do), and (2) applying
text via the pattern
argument (the default is to apply nothing). All of
this is useful when don't want to modify the input data other than to
decorate it within a pattern. Also, this function is useful when used as the
formatter
function in the summary_rows()
function, where the output may
be text or useful as is.
fmt_passthrough(data, columns, rows = NULL, escape = TRUE, pattern = "{x}")
data | A table object that is created using the |
---|---|
columns | The columns to format. Can either be a series of column names
provided in |
rows | Optional rows to format. Not providing any value results in all
rows in |
escape | An option to escape text according to the final output format
of the table. For example, if a LaTeX table is to be generated then LaTeX
escaping would be performed during rendering. By default this is set to
|
pattern | A formatting pattern that allows for decoration of the
formatted value. The value itself is represented by |
An object of class gt_tbl
.
Targeting of values is done through columns
and additionally by rows
(if
nothing is provided for rows
then entire columns are selected). A number of
helper functions exist to make targeting more effective. Conditional
formatting is possible by providing a conditional expression to the rows
argument. See the Arguments section for more information on this.
3-9
Other Format Data:
data_color()
,
fmt_currency()
,
fmt_datetime()
,
fmt_date()
,
fmt_markdown()
,
fmt_missing()
,
fmt_number()
,
fmt_percent()
,
fmt_scientific()
,
fmt_time()
,
fmt()
,
text_transform()
# Use `exibble` to create a gt table; # keep only the `char` column; # pass the data in that column through # but apply a simple pattern that adds # an 's' to the non-NA values tab_1 <- exibble %>% dplyr::select(char) %>% gt() %>% fmt_passthrough( columns = vars(char), rows = !is.na(char), pattern = "{x}s" )