num_as_ordinal | R Documentation |
num_as_ordinal
converts a given (cardinal) number
into an ordinal character sequence.
num_as_ordinal(x, sep = "")
x |
Number(s) to convert (required, scalar or vector). |
sep |
Decimal separator to use.
Default: |
The function currently only works for the English language and does not accepts inputs that are characters, dates, or times.
Note that the toOrdinal()
function of the toOrdinal package works
for multiple languages and provides a toOrdinalDate()
function.
Caveat: Note that this function illustrates how numbers,
characters, for
loops, and paste()
can be combined
when writing functions.
It is instructive, but not written efficiently or well
(see the function definition for an alternative solution
using vector indexing).
toOrdinal()
function of the toOrdinal package.
Other numeric functions:
base2dec()
,
base_digits
,
dec2base()
,
is_equal()
,
is_wholenumber()
,
num_as_char()
,
num_equal()
Other utility functions:
base2dec()
,
base_digits
,
dec2base()
,
is_equal()
,
is_vect()
,
is_wholenumber()
,
num_as_char()
,
num_equal()
num_as_ordinal(1:4)
num_as_ordinal(10:14) # all with "th"
num_as_ordinal(110:114) # all with "th"
num_as_ordinal(120:124) # 4 different suffixes
num_as_ordinal(1:15, sep = "-") # using sep
# Note special cases:
num_as_ordinal(NA)
num_as_ordinal("1")
num_as_ordinal(Sys.Date())
num_as_ordinal(Sys.time())
num_as_ordinal(seq(1.99, 2.14, by = .01))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.