Learn R Programming

textclean (version 0.3.0)

replace_number: Replace Numbers With Text Representation

Description

Replaces numeric represented numbers with words (e.g., 1001 becomes one thousand one).

Usage

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

Arguments

x
The text variable.
num.paste
logical. If FALSE the elements of larger numbers are separated with spaces. If TRUE the elements will be joined without spaces.
remove
logical. If TRUE numbers are removed from the text.
...
Other arguments passed to as.english

Value

Returns a vector with abbreviations replaced.

References

Fox, J. (2005). Programmer's niche: How do you spell that number? R News. Vol. 5(1), pp. 51-55.

Examples

Run this code
x <- c(
    NA, 
    'then .456 good', 
    'none', 
    "I like 346,457 ice cream cones.", 
    "I like 123456789 cashes.",     
    "They are 99 percent good and 45678.2345667"
)
replace_number(x)
replace_number(x, num.paste = TRUE)
replace_number(x, remove=TRUE)

Run the code above in your browser using DataLab