Abbreviate numbers for compact, uniform axis/graphic labels
Source:R/03-02-histogram.R
abbrev_num.RdFormats numbers with K/M/B/T suffixes (thousands, millions, billions, trillions) at a fixed number of significant figures, so labels stay short and roughly the same width. Negatives keep their sign; `0` maps to `"0"`. Vectorised.
Examples
abbrev_num(c(-61467591, 100, 3.9, 4178522311))
#> [1] "-61.5M" "100" "3.9" "4.18B"