Skip to contents

Tests whether each element is a currency amount — a numeric value carrying a currency symbol ($, €, £, ¥) as a prefix or suffix, with optional sign, grouping separators, decimals and interior spaces: "$-45", "$2300.00", "17,298$", "2300,00€", "€ 17.298", "-45€", "$1,000".

Usage

is_currency_amount(x)

Arguments

x

A character vector of candidate values.

Value

A logical vector: TRUE for a symbol-bearing numeric amount, FALSE otherwise, NA where x is NA.

Details

The symbol is required. A bare number ("1234", "-45.10") is deliberately not a currency amount at the value level — it is indistinguishable from a count or any other quantity (that is the symbol-less balance case, which is metadata-gated). Requiring the symbol is what makes the detector selective.

Examples

is_currency_amount(c("$2300.00", "17,298$", "-45€", "1234", NA))
#> [1]  TRUE  TRUE  TRUE FALSE    NA
#> TRUE TRUE TRUE FALSE NA