numeric_friendly(c(1/3, 0, 0.999, NA, NaN, Inf, -Inf))
# Specify the translations of "special" numbers
numeric_friendly(c(1, 0, Inf), zero = "none", inf = "all")
# Modify the output formatting
frac <- 8765.4321
numeric_friendly(frac)
numeric_friendly(frac, decimal = " dot ")
numeric_friendly(frac, hyphenate = TRUE, hyphenate_fractional = FALSE)
numeric_friendly(frac, and = TRUE, and_fractional = TRUE, decimal = " . ")
# The `friendlynumber.numeric.digits` option specifies the number of
# numeric digits mentioned by `numeric_friendly()`
opts <- options()
options(friendlynumber.numeric.digits = 5)
numeric_friendly(0.0987654321)
options(friendlynumber.numeric.digits = 10)
numeric_friendly(0.0987654321)
options(opts)
# Set `english_fractions` to specify the translation of certain
# fractions. The names (keys) of `english_fractions` should match
# the decimal part of a fraction (e.g. `"5"` matches `0.5`).
numeric_friendly(
c(1/2, 6/5, 12),
english_fractions = c(`5` = "1/2", `2` = "1/5")
)
# Input validation
try(numeric_friendly_safe("A"))
Run the code above in your browser using DataLab