Apply format strings to numeric values
apply_formats.RdVectorized formatting function. Takes an f_str object and numeric vectors, returns a character vector of formatted strings.
Usage
apply_formats(
fmt,
...,
precision = NULL,
lt = NULL,
gt = NULL,
lt_gt_group = NULL,
na = NULL,
width = NULL,
pad = c("right", "left")
)Arguments
- fmt
An f_str object or character format string
- ...
Numeric vectors, one per variable in the f_str (positional matching)
- precision
Optional list of resolved precision per group (for auto-precision)
- lt
Optional numeric less-than threshold applied to the group named by
lt_gt_group: values in(0, lt)render as"<" lt(seeformat_number_vec()).- gt
Optional numeric greater-than threshold applied to the group named by
lt_gt_group: values in(gt, 100)render as">" gt.- lt_gt_group
Optional integer index of the format group to which
lt/gtapply (used by count layers to target the percent statistic). NULL disables.- na
Optional string substituted for cells whose format-group inputs are all NA, used instead of the default blank-width fill.
na = ""produces a truly empty cell (nchar0);na = "NE"renders"NE". The defaultNULLpreserves the blank-width fill. This letsapply_formats()replace hand-rolled fixed-width formatters for externally row-bound statistics.- width
Optional integer total width to pad each formatted token to, using
stringr::str_pad(). When thenasubstitution applies to a cell,nawins and that cell is not padded. The defaultNULLleaves tokens at their natural format width.- pad
Side to pad on when
widthis set:"right"(default, trailing spaces) or"left"(leading spaces).