Adds ordinal suffixes to numbers (or a character vector of number-like words). Converts numeric vectors to cardinal numbers before adding prefixes unless cardinal is FALSE.

ordinal(x, cardinal = TRUE, ...)

nom_ord(x, cardinal = TRUE, ...)

Arguments

x

A numeric or character vector.

cardinal

Whether to convert a numeric vector with cardinal() before applying ordinal suffixes. When TRUE, 1 -> "first". When FALSE, 1 -> "1st". Defaults to TRUE.

...

Further arguments passed to cardinal() when cardinal is TRUE.

Value

A character vector of the same length as x

See also

Other number names: adverbial(), cardinal(), collective(), denominator(), numerator(), ratio()

Examples

nom_ord(2)
#> [1] "second"
nom_ord(1:10)
#>  [1] "first"   "second"  "third"   "fourth"  "fifth"   "sixth"   "seventh"
#>  [8] "eighth"  "ninth"   "tenth"  
nom_ord(525600)
#> [1] "five-hundred-twenty-five-thousand-six-hundredth"

nom_ord(1:10, cardinal = FALSE)
#>  [1] "1st"  "2nd"  "3rd"  "4th"  "5th"  "6th"  "7th"  "8th"  "9th"  "10th"
nom_ord(5:15, max_n = 10)
#>  [1] "fifth"   "sixth"   "seventh" "eighth"  "ninth"   "tenth"   "11th"   
#>  [8] "12th"    "13th"    "14th"    "15th"   

nom_ord(c("n", "dozen", "umpteen", "eleventy", "one zillion"))
#> [1] "nth"           "dozenth"       "umpteenth"     "eleventieth"  
#> [5] "one-zillionth"
nom_ord(9 + 3/4)
#> [1] "nine-and-three-quartersth"