Factory functions: each returns a function compatible with
scales::label_* (callable on a numeric vector). Marks (thousands,
decimals) and currency symbols come from the active ggconsulting
locale, set via ct_locale().
fmt_number()— plain numbers with locale separators.fmt_brl()— Brazilian Real. Always renders asR$regardless of active locale; thelocaleargument lets you override marks.fmt_currency()— uses the active locale's currency symbol.fmt_pct()— percentages, interpreting input as a fraction (0.5→"50%").fmt_delta()— percentage-point-style signed deltas (+1,2pp/-0,3pp/0,0pp).fmt_month()— Date / POSIXct → localised month string.
Negatives default to a minus prefix; currency helpers also support
style = "accounting", which wraps negatives in parentheses. Currency
rendering uses a non-breaking space (U+00A0) between symbol and
number so the pair never wraps across lines.
Usage
fmt_number(decimals = 0, locale = NULL)
fmt_brl(decimals = 2, style = c("minus", "accounting"), locale = NULL)
fmt_currency(decimals = 2, style = c("minus", "accounting"), locale = NULL)
fmt_pct(decimals = 1, locale = NULL, accuracy = NULL)
fmt_delta(decimals = 1, suffix = "pp", locale = NULL)
fmt_month(format = c("abbr", "full"), locale = NULL)Arguments
- decimals
Number of decimal places.
- locale
Optional locale name. Defaults to the active locale.
- style
"minus"(default) or"accounting"for currency.- accuracy
Optional explicit accuracy passed to
scales::percent(); overridesdecimalsif set.- suffix
Suffix for
fmt_delta(). Defaults to"pp".- format
"abbr"(default) or"full"forfmt_month().