Package 'toOrdinal'

Title: Cardinal to Ordinal Number & Date Conversion
Description: Language specific cardinal to ordinal number conversion.
Authors: Damian W. Betebenner [aut, cre], Andrew Martin [ctb], Jeff Erickson [ctb]
Maintainer: Damian W. Betebenner <[email protected]>
License: GPL-3
Version: 1.3-9.1
Built: 2025-03-09 02:40:22 UTC
Source: https://github.com/centerforassessment/toordinal

Help Index


Cardinal to Ordinal Number Conversion

Description

Language specific cardinal to ordinal number conversion.

Details

Package: toOrdinal
Type: Package
Version: 1.3-9.1
Date: 2024-12-3
License: GPL-3
LazyLoad: yes

Author(s)

Damian W. Betebenner [email protected]


Cardinal to ordinal number conversion function

Description

Function for converting cardinal to ordinal numbers by adding a language specific ordinal indicator (http://en.wikipedia.org/wiki/Ordinal_indicator) to the number.

Usage

toOrdinal(                                                  
	cardinal_number,
	language="English",
	convert_to="ordinal_number")

Arguments

cardinal_number

Postive integer (cardinal number) to be converted to an ordinal number. For example 1 becomes 1st, 2 becomes 2nd, ...

language

OPTIONAL. Language (defaults to English) indicating what language rules to use in conversion to ordinal number.

convert_to

OPTIONAL. Output type that provided 'cardinal_number' is converted into. Default is 'ordinal_number' which refers to the 'cardinal_number' followed by the appropriate ordinal indicator. Additional options planned include 'ordinal_word'.

Details

Typical use of the function is to submit a positive integer for conversion to an ordinal number in the language specified. See examples.

Value

Function returns the ordinal number or ordinal word (as a character string).

Author(s)

Damian W. Betebenner [email protected]

Examples

toOrdinal(1)  ## 1st
toOrdinal(1, language="French") ## 1re

toOrdinal(1:20) ## 1st, 2nd, 3rd, ...
toOrdinal(1:25, language="French") ## 1re, 2e, 3e, ...

Convert date to ordinal calendar date

Description

Function for converting a calendar date to it long, ordinal version.

Usage

toOrdinalDate(
	date=NULL,
	language="English")

Arguments

date

Either NULL (the default which uses the current date returned via Sys.date() or a character string of the form YYYY-MM-DD.

language

OPTIONAL. Language (defaults to English) indicating what language rules to use in conversion to ordinal number.

Details

Typical use of the function is to call the function with any argument to get the current date in long, ordinal form. See examples.

Value

Function returns the character string with the long, ordinal calendar date.

Author(s)

Damian W. Betebenner [email protected]

Examples

toOrdinalDate()
toOrdinalDate("2017-10-9") ## October 9th, 2017
toOrdinalDate("2017-10-09") ## October 9th, 2017
toOrdinalDate(c("2022-11-21", "2019-1-3", "1976-2-2", "1965-2-18"))
## "November 21st, 2022" "January 3rd, 2019" "February 2nd, 1976" "February 18th, 1965"