Determine the appropriate unit for a value (e.g., 1000000 = '1 Million'.

xunits(value, val_under_x_words = 10, words = TRUE)

Arguments

value

A numeric value.

val_under_x_words

a numeric that defines what values should be words as opposed to characters in a text. For example, many styles prefer that all values from 0 to 10 are spelled out in words, so you would set this parameter to 10 (which is the default). Set this parameter to NULL for nothing to to be spelled out.

words

T/F. Default = TRUE. If TRUE, "1000000" would become "1 Million" and if FALSE would become "1,000,000".

Examples

xunits(value = NA)
#> [1] NA
xunits(value = c(0, 1))
#> [1] "zero" "one" 
xunits(value = c(0, 1), val_under_x_words = 0)
#> [1] "zero" "1"   
xunits(value = 12)
#> [1] "12"
xunits(value = c(12345, 123456, 1234567))
#> [1] "12,345"      "123,456"     "1.2 million"
xunits(value = 123456789)
#> [1] "123.5 million"
xunits(value = 123456789, words = FALSE)
#> [1] "123,456,789"