The R package toOrdinal contains a single function toOrdinal
that converts a cardinal number (e.g., 9) into its ordinal counterpart (e.g., 9th).
Because such conversions are language specific, the conversions are specific to a supported language. At present, the package implements English,
French, German, Spanish, and Swedish. For example,
To install the latest stable release of toOrdinal from CRAN
> install.packages("toOrdinal")
To install the development release of toOrdinal from GitHub:
> devtools::install_github("CenterForAssessment/toOrdinal")
> toOrdinal(5)
[1] "5th"
> toOrdinal(5, language="German")
[1] "5te"
> toOrdinal(5, language="French")
[1] "5e"
> toOrdinal(5, language="Spanish")
[1] "5.ยบ"
> toOrdinal(5, language="Swedish")
1] "5:e"
The toOrdinal Package is crafted with :heart: by:
I love feedback and am happy to answer questions. Feel free to clone and make a pull request with the specifications for other languages.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.