Skip to contents

Convert numeric value to a string abbreviation with K, M, B for Thousand, Million & Billion

Usage

num2str(
  x,
  sf = 2,
  outtype = c("abbreviated", "with_suffix", "rounded"),
  suffix_lb = "K"
)

Arguments

x

num

sf

num significant figures to round to

outtype

chr Format of the outtype

  • abbreviated takes the form XX where X are digits

  • with_suffix takes the form XXS where X are digits and S is the suffix

  • rounded takes the form XX.XX rounded with sf sig figs

Value

chr

Examples

num2str(10000)
#> [1] "10K"