Skip to contents

Format Numeric Values

Usage

format_num(
  num,
  format = "auto",
  decimals = 1,
  threshold = 10000,
  format_list = c("", "K", "M", "B", "T")
)

Arguments

num

Number or numeric vector

format

Format for numeric output - "auto", "K", "M", "B" or "T"

decimals

Number of decimal numbers for rounding

threshold

Threshold for converting to a specific format, below threshold only thousand delimiters will be added

format_list

List of formats to use for automated

Value

character() vector

Examples

format_num(27334254)
#> [1] "27.3 M"
format_num(c(27334254, 12332, 23425435534))
#> [1] "27.3 M" "12.3 K" "23.4 B"