The 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 Dutch, English, French, German,
Spanish, and Swedish. For example,
After installing the package from either CRAN or GitHub, it’s simple to convert a cardinal to an ordinal number.
To convert cardinal to ordinal numbers in English (the default),
supply the cardinal number to toOrdinal
.
Conversion in other languages are performed by supplying the
appropriate language to the language
argument:
> toOrdinal(5, language="Dutch")
[1] "5de"
> 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"
Current languages supported include: English, German, French, Spanish, and Swedish.
Since Version 1.1, the function toOrdinalDate
converts
calendar dates to a long format, ordinal form.
If no argument is provided to toOrdinalDate
, then the
current date derived from Sys.date()
is used to create the
ordinal version of the calendar date. If a date is supplied, then it
must be supplied as a character string of the form “YYYY-MM-DD” that is
then converted to the more formal date format. Like with the function
toOrdinal
the potential exists for multiple language
support with toOrdinalDate
. However, the only language
currently supported by toOrdinalDate
is English.
If you have contribution (for example, another language) or a feature request for the toOrdinal package, don’t hesitate to write or set up an issue on GitHub. Current new features include the possiblity of converting cardinal numbers to ordinal words (e.g., 8 to eighth).