text2num {JATSdecoder} | R Documentation |
text2num
Description
Converts special annotated number and written numbers in a text string to a fully digit representation. Can handle numbers with exponent, fraction, percent, e+num, products and written representation (e.g. 'fourtys-one') of all absolut numbers up to 99,999 (Note: gives wrong output for higher spelled numbers). Process is performed in the same order as its arguments.
Usage
text2num(
x,
exponent = TRUE,
percentage = TRUE,
fraction = TRUE,
e = TRUE,
product = TRUE,
words = TRUE
)
Arguments
x |
text string to process. |
exponent |
Logical. If TRUE values with exponent are converted to a digit representation. |
percentage |
Logical. If TRUE percentages are converted to a digit representation. |
fraction |
Logical. If TRUE fractions are converted to a digit representation. |
e |
Logical. If TRUE values denoted with 'number e+number' (e.g. '2e+2') or number*10^number are converted to a digit representation. |
product |
Logical. If TRUE values products are converted to a digit representation. |
words |
Logical. If TRUE written numbers are converted to a digit representation. |
Value
Character. Text with unified digital representation of numbers.
Examples
x<-c("numbers with exponent: 2^2, -2.5^2, (-3)^2, 6.25^.5, .2^-2 text.",
"numbers with percentage: 2%, 15 %, 25 percent.",
"numbers with fractions: 1/100, -2/5, -7/.1",
"numbers with e: 10e+2, -20e3, .2E-2, 2e4",
"numbers as products: 100*2, -20*.1, 2*10^3",
"written numbers: twenty-two, one hundred fourty five, fifteen percent",
"mix: one hundred ten is not 1/10 is not 10^2 nor 10%/5")
text2num(x)