Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

replace_ordinal

Replace Mixed Ordinal Numbers With Text Representation


Description

Replaces mixed text/numeric represented ordinal numbers with words (e.g., "1st" becomes "first").

Usage

replace_ordinal(x, num.paste = FALSE, remove = FALSE, ...)

Arguments

x

The text variable.

num.paste

logical. If TRUE a the elements of larger numbers are separated with spaces. If FALSE the elements will be joined without spaces.

remove

logical. If TRUE ordinal numbers are removed from the text.

...

ignored.

Note

Currently only implemented for ordinal values 1 through 100

Examples

x <- c(
    "I like the 1st one not the 22nd one.", 
    "For the 100th time stop!"
)
replace_ordinal(x)
replace_ordinal(x, TRUE)
replace_ordinal(x, remove = TRUE)
replace_number(replace_ordinal("I like the 1st 1 not the 22nd 1."))

textclean

Text Cleaning Tools

v0.9.3
GPL-2
Authors
Tyler Rinker [aut, cre], ctwheels StackOverflow [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.