number_friendly {friendlynumber} | R Documentation |
Translate a vector of numbers to a cardinal character vector
Description
Convert a vector of numbers to a cardinal numeral (e.g. one tenth, one, two).
number_friendly_safe()
checks that all arguments are of the correct type
and raises an informative error otherwise. number_friendly()
does not
perform input validation to maximize its speed.
Usage
number_friendly(numbers, ...)
## S3 method for class 'numeric'
number_friendly(
numbers,
zero = "zero",
na = "missing",
nan = "not a number",
inf = "infinity",
negative = "negative ",
decimal = " and ",
and = FALSE,
hyphenate = TRUE,
and_fractional = and,
hyphenate_fractional = hyphenate,
english_fractions = NULL,
...
)
## S3 method for class 'integer'
number_friendly(
numbers,
zero = "zero",
na = "missing",
nan = "not a number",
inf = "infinity",
negative = "negative ",
and = FALSE,
hyphenate = TRUE,
...
)
## S3 method for class 'bignum_biginteger'
number_friendly(
numbers,
zero = "zero",
na = "missing",
nan = "not a number",
inf = "infinity",
negative = "negative ",
and = FALSE,
hyphenate = TRUE,
...
)
## S3 method for class 'bignum_bigfloat'
number_friendly(
numbers,
zero = "zero",
na = "missing",
nan = "not a number",
inf = "infinity",
negative = "negative ",
decimal = " and ",
and = FALSE,
hyphenate = TRUE,
and_fractional = and,
hyphenate_fractional = hyphenate,
english_fractions = NULL,
...
)
## Default S3 method:
number_friendly(numbers, ...)
number_friendly_safe(numbers, ...)
## S3 method for class 'numeric'
number_friendly_safe(
numbers,
zero = "zero",
na = "missing",
nan = "not a number",
inf = "infinity",
negative = "negative ",
decimal = " and ",
and = FALSE,
hyphenate = TRUE,
and_fractional = and,
hyphenate_fractional = hyphenate,
english_fractions = NULL,
...
)
## S3 method for class 'integer'
number_friendly_safe(
numbers,
zero = "zero",
na = "missing",
nan = "not a number",
inf = "infinity",
negative = "negative ",
and = FALSE,
hyphenate = TRUE,
...
)
## S3 method for class 'bignum_biginteger'
number_friendly_safe(
numbers,
zero = "zero",
na = "missing",
nan = "not a number",
inf = "infinity",
negative = "negative ",
and = FALSE,
hyphenate = TRUE,
...
)
## S3 method for class 'bignum_bigfloat'
number_friendly_safe(
numbers,
zero = "zero",
na = "missing",
nan = "not a number",
inf = "infinity",
negative = "negative ",
decimal = " and ",
and = FALSE,
hyphenate = TRUE,
and_fractional = and,
hyphenate_fractional = hyphenate,
english_fractions = NULL,
...
)
## Default S3 method:
number_friendly_safe(numbers, ...)
Arguments
numbers |
A vector of numbers to translate. The friendlynumber package defines
methods for integer, numeric,
|
... |
Additional arguments passed to or from other methods. |
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 |
decimal |
A word inserted between the whole and fractional part of translated
|
and |
Whether to insert an |
hyphenate |
Whether to hyphenate numbers 21 through 99 (e.g. |
and_fractional |
Whether to insert an
|
hyphenate_fractional |
Whether to hyphenate numbers 21 through 99 in the fractional part of translated
|
english_fractions |
A named character vector used as a dictionary for the translation of the
fractional part of For example By default Provide an empty character to |
Value
A non-NA character vector of the same length as numbers
.
See Also
integerish_friendly()
, numeric_friendly()
,
biginteger_friendly()
, bigfloat_friendly()
Examples
number_friendly(c(1/3, 0, 0.999, NA, NaN, Inf, -Inf))
number_friendly(c(1L, 2L, 1001L))
# Input validation
try(number_friendly_safe(1L, zero = c("a", "zero")))