Learn R Programming

doseminer (version 0.1.2)

replace_numbers: Replace English number phrases with their decimal representations

Description

Uses numb_replacements to match parts of a string corresponding to numbers, then invokes words2number to convert these substrings to numeric. The rest of the string (the non-number words) is left intact.

Usage

replace_numbers(string)

Arguments

string

A character vector. Can contain numbers and other text

Value

A character vector the same length as string, with words replaced by their decimal representations.

Details

Works on non-negative integer numbers under one billion (one thousand million). Does not support fractions or decimals (yet).

See Also

words2number, for use on cleaned text that does not contain any non-number words

Examples

Run this code
# NOT RUN {
replace_numbers('Two plus two equals four')
replace_numbers('one hundred thousand dollars!')
replace_numbers(c('A vector', 'containing numbers', 'like thirty seven'))

# }

Run the code above in your browser using DataLab