ExtractCurrency: Extract Currency

Description Usage Arguments Examples

View source: R/format-text.R

Description

This function takes a text string and extracts the dollar amount identified as numeric, allowing the suffixes K (thousand), M (million), B (billion), and T (trillion)

Usage

1

Arguments

string

String to search for dollar amounts

debug

If TRUE, print debug output

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ExtractCurrency('$11')

ExtractCurrency('$100 total')

ExtractCurrency('Receipt of $11.57')

ExtractCurrency('$10K-$100K', debug = TRUE) # Returns 10,000 (first match)

strings <- c('Nearly $23K', 'A $200M Powerball', 'A $3B endowment', 'GDP last year of $17.1T (USD)')
ExtractCurrency(strings, debug = TRUE)

phively/wranglR documentation built on April 11, 2020, 5:12 a.m.