filesstrings (version 0.4.0)

GetCurrencies: Get the currencies of numbers within a string.

Description

The currency of a number is defined as the character coming before the number in the string. If nothing comes before (i.e. if the number is the first thing in the string), the currency is the empty string, similarly the currency can be a space, comma or any manner of thing.

  • GetCurrency takes a string and returns the currency of the first number therein. It is vectorised over string.

  • GetCurrencies takes a string and returns the currencies of all of the numbers within that string. It is not vectorised.

Usage

GetCurrencies(string)

GetCurrency(strings)

Arguments

string

A string.

strings

A character vector.

Value

  • GetCurrency returns a character vector.

  • GetCurrencies returns a data frame with one column for the currency symbol and one for the amount.

Details

These functions do not allow for leading decimal points.

Examples

Run this code
GetCurrencies("35.00 $1.14 abc5 $3.8 77")
GetCurrency(c("ab3 13", "$1"))

Run the code above in your browser using DataLab