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,
- English: toOrdinal(1) returns '1st'
- Dutch: toOrdinal(1, language="Dutch") returns '1ste'
- German: toOrdinal(1, language="German") returns '1te'
- French: toOrdinal(1, language="French") returns '1re'
- Spanish: toOrdinal(1, language="Spanish") returns '1.er'
- Swedish: toOrdinal(1, language="Swedish") returns '1:a'
From CRAN
To install the latest stable release of toOrdinal from CRAN
> install.packages("toOrdinal")
From Github
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 ❤️ 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.