View source: R/integerish-friendly.R
integerish_friendly | R Documentation |
Convert an integer vector, or numeric vector which is coercible to an integer without loss of precision, to a cardinal numeral (e.g. one, two, three).
integerish_friendly_safe()
checks that all arguments are of the correct type
and raises an informative error otherwise. integerish_friendly()
does not
perform input validation to maximize its speed.
integerish_friendly(
numbers,
zero = "zero",
na = "missing",
nan = "not a number",
inf = "infinity",
negative = "negative ",
and = FALSE,
hyphenate = TRUE
)
integerish_friendly_safe(
numbers,
zero = "zero",
na = "missing",
nan = "not a number",
inf = "infinity",
negative = "negative ",
and = FALSE,
hyphenate = TRUE
)
numbers |
An integer or integer-ish numeric vector to translate. |
zero |
What to call values of |
na |
What to call values of |
nan |
What to call values of |
inf |
What to call values of |
negative |
A prefix added to the translation of negative elements of |
and |
Whether to insert an |
hyphenate |
Whether to hyphenate numbers 21 through 99 (e.g. |
A non-NA character vector of the same length as numbers
.
integerish_friendly(c(0, 1, 2, NA, NaN, Inf, -Inf))
integerish_friendly(10^10)
# Specify the translations of "special" numbers
integerish_friendly(-10, negative = "minus ")
integerish_friendly(NaN, nan = "undefined")
# Modify the output formatting
integerish_friendly(1234)
integerish_friendly(1234, and = TRUE)
integerish_friendly(1234, hyphenate = FALSE)
# Input validation
try(integerish_friendly_safe(0.5))
try(integerish_friendly_safe(1L, na = TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.