Turns plain integers into ordinals: 1 becomes 1st, 2 becomes 2nd, 23 becomes 23rd. The suffix can be rendered as superscript, which is the usual treatment in a ranked column.
Details
Teens are handled correctly, so 11, 12 and 13 take "th" and not "st", "nd" and "rd". Values that are not numeric are left alone.
Examples
library(gt)
nfc <- subset(
sdv_example_standings, conference == "NFC" & conference_rank <= 5,
c(team_name, conference_rank)
)
nfc <- nfc[order(nfc$conference_rank), ]
gt(nfc) |> gt_fmt_rank(conference_rank)
team_name
conference_rank
# flat, without the superscript
gt(nfc) |> gt_fmt_rank(conference_rank, superscript = FALSE)
team_name
conference_rank
