| display {flextable} | R Documentation |
Modify flextable displayed values by specifying a string expression. Function is handling complex formatting as well as image insertion.
display(x, i = NULL, col_key, pattern, formatters = list(), fprops = list(), part = "body")
x |
a flextable object |
i |
rows selection |
col_key |
column to modify, a single character |
pattern |
string to format |
formatters |
a list of formula, left side for the name, right side for the content. |
fprops |
a named list of fp_text |
part |
partname of the table (one of 'all', 'body', 'header', 'footer') |
It defined the template used to format the produced strings. Names enclosed
by double braces will be evaluated as R code, the corresponding R code is defined
with the argument formatters.
Each compound is specifying the R code to execute to produce strings that will be
substituted in the pattern argument. An element must be a formula: the
left-hand side is a name (matching a name enclosed by double braces in
pattern) and the right-hand side is an R expression to be evaluated (that
will produce the corresponding strings).
The function is designed to work with columns in the dataset provided to
flextable (the col_keys).
A named list of fp_text. It defines the formatting properties
associated to a compound in formatters. If not defined for an element
of formatters, the default formatting properties will be applied.
The function display only works with flextable objects,
use set_formatter for regulartable objects.
library(officer)
# Formatting data values example ------
ft <- flextable(head( mtcars, n = 10))
ft <- display(ft, col_key = "carb",
i = ~ drat > 3.5, pattern = "# {{carb}}",
formatters = list(carb ~ sprintf("%.1f", carb)),
fprops = list(carb = fp_text(color="orange") ) )
ft <- autofit(ft)