- Non-finite inputs (
NA,Inf, andNaN) no longer produce an error.Infis handled like a normal number.nom_card(Inf)produces"infinity"andnom_ord(Inf)produces"infinitieth".NAandNaNpropagate through functions. All functions returnNAforNAand"NaN"forNaN.
- The logic in
ordinal()has been simplified and now runs slightly faster.
- Added
ratio(), which generates ratios.ratio("0.5")generates "one in two".ratio("1.5", sep = "to")generates "three to two".
- Removed
pkgconfiginterface for setting default options.- Options should now be set within function calls or by creating helper functions with different defaults.
-
Added
uncardinal(), which takes a character vector and attempts to convert it to a numeric.uncardinal("twenty-five")produces 25.- Currently,
uncardinal()only works with cardinal integers and the result of other nombre functions.
-
nombre outputs are now part of the S3 class
nombre.- This allows
nombres to go through mathematical transformations while preserving their characteristics. cardinal(25) + cardinal(2)produces"twenty-seven".adverbial(3) / 3produces"once".as.numeric(ordinal(9))produces9.
- This allows
-
Default arguments are now handled with pkgconfig rather than
options().- This allows packages that import nombre to set defaults without affecting the user or other packages.
-
Denominators that begin with "one" now omit the leading "one".
cardinal(3/100)now produces "three hundredths" rather than "three one-hundredths".denominator(1)still produces "whole".
-
collective()gains the argumentsof_the,all_n, andcardinal.collective(3, all_n = FALSE)becomes"all"rather than"all three".collective(0:3, of_the = TRUE)becomesc("none of the", "the", "both of the", "all three of the")rather thanc("no", "the", "both", "all three").collective(3, cardinal = FALSE)becomes"all 3"rather than"all three".- The defaults can be changed with
set_config("nombre::all_n", "nombre::of_the", "nombre::coll_cardinal").
-
cardinal()loses the argumentnumerator.- Numerators should now be produced using
numerator()/nom_numer().
- Numerators should now be produced using
-
Decimals are now converted to fractions with fracture. This allows
cardinal()to generate fractional components in roughly one tenth the time of the R implementation ofdecimal_to_fraction().- Arguments are passed to
fracture::frac_mat()with....
- Arguments are passed to
-
Added a
pkgdownsite.
-
cardinal()gains the argumentmax_n, which stops numbers greater thatmax_nfrom being cardinalized. This is useful when you want to print small numbers in words but larger numbers numerically. Refactorization means this argument can be used by all functions.options("nombre.max_n")sets a default value.
-
adverbial()andnom_adv()generate adverbials, e.g. "once", "twice", "three times".thrice = TRUEoroptions("nombre.thrice" = TRUE)convert3to "thrice" instead of "three times".
-
All functions now pass
...to lower level functions.ordinal()andadverbial()pass tocardinal().denominator()passes toordinal(). This allowscardinal()'smax_nandnegativeto be used by all functions andordinal()'scardinalto be used bydenominator().
ordinal()now handles uncardinalized numeric vectors with different numbers of digits correctly. Previously, dashes would be appended to the start of the shorter numbers.nom_ord(c(9, 10), cardinal = FALSE)now produces "9th, 10th" as expected, instead of "-9th, 10th" as it did previously.
-
Implemented a custom function to convert decimals to fractions. This removes the previous previous dependency on {MASS}.
-
Added package documentation page at
?nombre
- Initial release