Learn R Programming

qdap (version 2.4.6)

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(text.var, num.paste = TRUE, remove = FALSE)

Arguments

text.var

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.

See Also

bracketX, qprep, replace_abbreviation, replace_contraction, replace_symbol, replace_number

Examples

Run this code
if (FALSE) {
x <- c(
    "I like the 1st one not the 22nd one.", 
    "For the 100th time stop!"
)
replace_ordinal(x)
replace_ordinal(x, FALSE)
replace_ordinal(x, remove = TRUE)
"I like the 1st 1 not the 22nd 1." %>% replace_ordinal %>% replace_number
}

Run the code above in your browser using DataLab