replace_number: Replace Numbers With Text Representation

Description Usage Arguments Value Note References Examples

Description

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

Usage

1
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.

Value

Returns a vector with abbreviations replaced.

Note

The user may want to use replace_ordinal first to remove ordinal number notation. For example replace_number would turn "21st" into "twenty onest", whereas replace_ordinal would generate "twenty first".

References

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

Examples

1
2
3
4
5
6
x <- c("I like 346,457 ice cream cones.", "They are 99 percent good")
y <- c("I like 346457 ice cream cones.", "They are 99 percent good")
replace_number(x)
replace_number(y)
replace_number(x, num.paste = TRUE)
replace_number(x, remove=TRUE)

trinker/textcleanLite documentation built on June 1, 2019, 12:52 a.m.