format_number_hdx {gghdx}R Documentation

Format numbers in HDX style

Description

Does the formatting found in label_number_hdx.

Usage

format_number_hdx(x, additional_prefix)

Arguments

x

Numeric vector to format

additional_prefix

Additional prefix to add to string, that will come between sign_prefix and the number. For example, "$" could produce a return value of ⁠-$1.1K⁠.

Details

Just for continuity, values are labeled with T for trillion, and that is the maximum formatting available, anything above the trillions will continue to be truncated to report in the trillions.

Deals with negative values in case those ever need to be formatted in similar manners. Also ensures that rounding is performed so numbers look correct. Not to be used for percents, which should just use scales::label_percent().

Designed like the ⁠scales::⁠ family of label functions, the return value of label_number_hdx is a function, based on the additional_prefix. So you should pass it in to scales_...() labels parameter in the same way as scales_...()

Value

Character vector of formatted strings


[Package gghdx version 0.1.3 Index]