human.numbers: Human Numbers For ggplot2 Graph Axis

human.numbersR Documentation

Human Numbers For ggplot2 Graph Axis

Description

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.

Usage

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)

Arguments

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.

Details

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.

Value

A character vector the same length as the input vector

Author(s)

Omer Kara

References

These functions are taken from here.

Examples

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)


omerkara/okara documentation built on Nov. 21, 2023, 7:56 p.m.