CurrencyToNumeric: Currency String To Numeric

Description Usage Arguments Examples

View source: R/format-text.R

Description

This function takes a vector or data frame of currency values in character format, strips out comma delimiters and currency symbols, and converts the result to numeric.

Usage

1

Arguments

data

Data frame or character vector to be manipulated

fields

Character vector of fields; not necessary if passing a vector

debug

If TRUE, print debug output

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
cash <- c("10,203¢", "$340", "€8,111.10", "£23,040", "¥8300")
CurrencyToNumeric(cash)

cash.frame <- data.frame(c1 = cash, c2 = cash, c3 = cash, stringsAsFactors = FALSE)

CurrencyToNumeric(cash.frame)
# Note that this unlists the data because no fields were included

CurrencyToNumeric(cash.frame, fields=1:2)
CurrencyToNumeric(cash.frame, fields=c("c2", "c3"))

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