human.numbers | R Documentation |
This set of functions formats the numbers in a ggplot2 graph axis so they are easily readable for humans. Use this function in a ggplot2 object for labels where you might use the comma or percent functions from the Scales package. Function checks whether numbers are positive or negative. It allows up to 1 significant figure and sapply used for element-wise application of the humanity function as a vector may include numbers where billions, millions or thousands are appropriate.
human_numbers(x = NULL, smbl = "", signif = 1)
human_num(x)
human_per(x)
human_gbp(x)
human_usd(x)
human_euro(x)
human_tl(x)
x |
numeric. a numeric vector to format. |
smbl |
character. a symbol you'd like to prefix your numbers by e.g. "$". |
signif |
numeric. the number of significant places you want the function to return. |
All conversions are in character. See below.
human_numbers: Main function with adjustable symbol and significant places.
human_num: For no symbol.
human_per: For percentage symbol.
human_gbp: For Pound symbol.
human_usd: For Dollar symbol.
human_euro: For Euro symbol.
human_tl: For TL symbol.
A character vector the same length as the input vector
These functions are taken from here.
human_numbers(c(1000000 , 1500000, 10000000000))
human_numbers(c(1.200000e+05, -2.154660e+05, 2.387790e+05, 4.343500e+04 ,5.648675e+12), "$")
## Not run:
ggplot2 + scale_y_continuous(labels = human_num)
ggplot2 + scale_x_continuous(labels = human_gbp)
ggplot2 + scale_x_continuous(labels = human_tl)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.