ordinal: Convert numbers to ordinal character vectors (first, second,...

View source: R/ordinal.R

ordinalR Documentation

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

Description

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.

Usage

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)
nom_ord(1:10)
nom_ord(525600)

nom_ord(1:10, cardinal = FALSE)
nom_ord(5:15, max_n = 10)

nom_ord(c("n", "dozen", "umpteen", "eleventy", "one zillion"))
nom_ord(9 + 3/4)

rossellhayes/nombre documentation built on June 2, 2022, 10:22 a.m.