This is a collection of small utilities for formatting numbers, especially for use in charts and tables. Many of them are simply wrappers around scales
functions.
Arguments
- x
A numeric vector
- ...
Additional arguments to pass to underlying
scales
functions, such asscales::percent
andscales::number
.
Details
round100
takes a decimal, such as a percentage, multiplies by 100, and rounds, e.g. 0.251
becomes "25"
, useful for then pasting with additional text (see examples).
percent100
adds on to round100
by appending a percent sign, e.g. 0.251
becomes "25%"
.
percent_lt1
takes an additional step, replacing any values below 1 percent with "<1%"
, useful for suppressing small numbers.