pretty_num: Linear quantities in a human readable string

pretty_numR Documentation

Linear quantities in a human readable string

Description

Use pretty_num() to format numbers compute_num() is the underlying engine that may be useful for custom formatting.

Usage

pretty_num(number, style = c("default", "nopad", "6"))

compute_num(number, smallest_prefix = "y")

Arguments

number

Numeric vector, number related to a linear quantity.

style

Formatting style:

  • "default" is the original pretty_num formatting, and it always pads the output, so that all vector elements are of the same width,

  • "nopad" is similar, but does not pad the output,

  • "6" always uses 6 characters, The "6" style is useful if it is important that the output always has the same width (number of characters), e.g. in progress bars. See some examples below.

smallest_prefix

A character scalar, the smallest prefix to use.

Value

Character vector, the formatted sizes. For compute_num, a data frame with columns amount, prefix, negative.

Examples

numbers <- c(1337, 1.3333e-5, 13333337, 1333333337, 133333333337)
pretty_num(numbers)
pretty_num(numbers, style = "nopad")
pretty_num(numbers, style = "6")

r-lib/prettyunits documentation built on March 9, 2024, 5:03 p.m.