The fmt()
function provides greater control in formatting raw data values
than any of the specialized fmt_*()
functions that are available in
gt. Along with the columns
and rows
arguments that provide some
precision in targeting data cells, the fns
argument allows you to define
one or more functions for manipulating the raw data.
If providing a single function to fns
, the recommended format is in the
form: fns = function(x) ...
. This single function will format the targeted
data cells the same way regardless of the output format (e.g., HTML, LaTeX,
RTF).
If you require formatting of x
that depends on the output format, a list of
functions can be provided for the html
, latex
, and default
contexts.
This can be in the form of fns = list(html = function(x) ..., latex = function(x) ..., default = function(x) ...)
. In this multiple-function case,
we recommended including the default
function as a fallback if all contexts
aren't provided.