Learn R Programming

nombre

nombre (French) /nɔ̃bʁ/: number
nombre (Spanish) /ˈnom.bɾe/: name
nombre: package to convert numbers to their names in R

nombre converts numeric vectors to character vectors of English words. You can use it to express numbers as cardinals (one, two, three) or ordinals (first, second, third), as well as numerators and denominators. nombre supports not just whole numbers, but also negatives, fractions, and ratios.

Installation

You can install the released version of nombre from CRAN with:

install.packages("nombre")

or the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("rossellhayes/nombre")

Usage

nombre converts numerics into words:

nom_card(2)
#> [1] "two"
nom_card(2L)
#> [1] "two"
x <- rep(TRUE, 525600)
nom_card(length(x))
#> [1] "five hundred twenty-five thousand six hundred"

It also works for numeric vectors:

nom_card(8^(1:10))
#>  [1] "eight"                                                                                       
#>  [2] "sixty-four"                                                                                  
#>  [3] "five hundred twelve"                                                                         
#>  [4] "four thousand ninety-six"                                                                    
#>  [5] "thirty-two thousand seven hundred sixty-eight"                                               
#>  [6] "two hundred sixty-two thousand one hundred forty-four"                                       
#>  [7] "two million ninety-seven thousand one hundred fifty-two"                                     
#>  [8] "sixteen million seven hundred seventy-seven thousand two hundred sixteen"                    
#>  [9] "one hundred thirty-four million two hundred seventeen thousand seven hundred twenty-eight"   
#> [10] "one billion seventy-three million seven hundred forty-one thousand eight hundred twenty-four"

nombre can also generate ordinals, adverbials, collectives, numerators and denominators:

nom_ord(1:5)
#> [1] "first"  "second" "third"  "fourth" "fifth"
nom_adv(1:5)
#> [1] "once"        "twice"       "three times" "four times"  "five times"
nom_coll(1:5)
#> [1] "the"       "both"      "all three" "all four"  "all five"
nom_numer(1:5)
#> [1] "one"   "two"   "three" "four"  "five"
nom_denom(1:5)
#> [1] "whole"   "half"    "third"   "quarter" "fifth"
nom_denom(1:5, numerator = 1:5)
#> [1] "whole"    "halves"   "thirds"   "quarters" "fifths"

Copy Link

Version

Install

install.packages('nombre')

Monthly Downloads

231

Version

0.4.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Alexander Rossell Hayes

Last Published

May 23rd, 2022

Functions in nombre (0.4.1)

numerator

Convert numbers to numerator character vectors (one, two, three)
denominator

Convert numbers to denominator character vectors (whole, half, third)
ordinal

Convert numbers to ordinal character vectors (first, second, third)
cardinal

Convert numbers to cardinal character vectors (one, two, three)
collective

Convert numbers to collective character vectors (the, both, all three)
adverbial

Convert numbers to adverbial character vectors (once, twice, three times)
ratio

Convert numbers to ratio character vectors (two to one, one in three, five out of ten)
uncardinal

Convert cardinal character vectors to numbers
nombre-package

nombre: Number Names