ordinal_format {scales}R Documentation

Ordinal formatter: add ordinal suffixes (-st, -nd, -rd, -th) to numbers.

Description

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

Usage

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

# Custom rules for French
french <- list(
  er = "^1$",
  nd = "^2$",
  e = "."
)
ordinal(1:20, rules = french)

# You can also use directly
ordinal(1:20, rules = ordinal_french())

[Package scales version 1.0.0 Index]