
Abbreviate large numbers with fixed decimals (k / M / B)
Source:R/dt2_formats.R
dt2_format_number_abbrev.RdAdds a columns.render function that displays numbers as 1.2k, 3.4M, etc.
This renderer lets you control the number of decimal places via digits.
Use this when you want a fixed, compact style independent of locale rules.
Usage
dt2_format_number_abbrev(
options = list(),
col_specs,
digits = 1,
locale = NULL
)Arguments
- options
A DataTables options list to be modified.
- col_specs
Column names or 1-based indices to format.
- digits
Integer, decimal places for the abbreviated display (default 1).
- locale
Optional BCP-47 locale string (e.g. "pt-BR"). If provided, the non-abbreviated part uses
toLocaleString(locale)for grouping.