ordinal_english(), ordinal_french() and ordinal_spanish() provide rules for computing ordinal indicators in English, French and Spanish respectively.

ordinal_format(prefix = "", suffix = "", big.mark = " ",
  rules = ordinal_english(), ...)

ordinal(x, prefix = "", suffix = "", big.mark = " ",
  rules = ordinal_english(), ...)

ordinal_english()

ordinal_french()

ordinal_spanish()

Arguments

prefix, suffix

Symbols to display before and after value.

big.mark

Character used between every 3 digits to separate thousands.

rules

Named list of regular expressions, match in order. Name gives suffix, and value specifies which numbers to match.

...

Other arguments passed on to base::format().

x

A numeric vector of positive values to format.

Value

A function with single parameter x, a numeric vector, that returns a character vector

Note

Values in x will be rounded before formating.

Examples

ordinal_format()(1:10)
#> [1] "1st" "2nd" "3rd" "4th" "5th" "6th" "7th" "8th" "9th" "10th"
ordinal(1:10)
#> [1] "1st" "2nd" "3rd" "4th" "5th" "6th" "7th" "8th" "9th" "10th"
# Custom rules for French french <- list( er = "^1$", nd = "^2$", e = "." ) ordinal(1:20, rules = french)
#> [1] "1er" "2nd" "3e" "4e" "5e" "6e" "7e" "8e" "9e" "10e" "11e" "12e" #> [13] "13e" "14e" "15e" "16e" "17e" "18e" "19e" "20e"
# You can also use directly ordinal(1:20, rules = ordinal_french())
#> [1] "1er" "2nd" "3e" "4e" "5e" "6e" "7e" "8e" "9e" "10e" "11e" "12e" #> [13] "13e" "14e" "15e" "16e" "17e" "18e" "19e" "20e"