Description Usage Arguments Functions Examples
Pretty print scaled numbers
1 2 3 4 5 6 7 8 9 10 11 12 | pretty_num(
x,
units = c(k = 1000, M = 1e+06, B = 1e+09),
decimal_digits = 1,
no_dot_zero = FALSE
)
format_pretty_num(
units = c(k = 1000, M = 1e+06, B = 1e+09),
decimal_digits = 1,
no_dot_zero = TRUE
)
|
x |
Vector of numbers |
units |
Named list with lower bounds for units. Names are units or unit abbreviations. |
decimal_digits |
Number of digits to show after the decimal point in the selected unit. |
no_dot_zero |
Should trailing |
format_pretty_num
: A label formatter for ggplot2
1 2 3 4 5 6 7 8 9 10 11 | pretty_num(1234)
pretty_num(12345, decimal_digits = 3)
pretty_num(123456789)
pretty_num(12345678900)
pretty_num(c(1234, 1234567, 12345678900))
library(ggplot2)
ggplot(mtcars) +
aes(mpg, wt * 1000) +
geom_point() +
scale_y_continuous(labels = format_pretty_num())
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.