Perform targeted text transformation with a function
text_transform(data, locations, fn)
| data | A table object that is created using the |
|---|---|
| locations | The cell or set of cells to be associated with the text
transformation. Only the |
| fn | The function to use for text transformation. |
An object of class gt_tbl.

3-12
Other Format Data:
data_color(),
fmt_bytes(),
fmt_currency(),
fmt_datetime(),
fmt_date(),
fmt_markdown(),
fmt_missing(),
fmt_number(),
fmt_passthrough(),
fmt_percent(),
fmt_scientific(),
fmt_time(),
fmt()
# Use `exibble` to create a gt table; # transform the formatted text in the # `num` and `currency` columns using # a function within `text_transform()`, # where `x` is a formatted vector of # column values tab_1 <- exibble %>% dplyr::select(num, char, currency) %>% dplyr::slice(1:4) %>% gt() %>% fmt_number(columns = num) %>% fmt_currency(columns = currency) %>% text_transform( locations = cells_body( columns = num ), fn = function(x) { paste0( x, " (", dplyr::case_when( x > 20 ~ "large", x <= 20 ~ "small"), ")") } )