Formats numbers with a thousand separator and a currency indicator.

num_currency(
  x,
  symbol = "$",
  digits = 2L,
  format = "f",
  big.mark = ",",
  ...,
  sep = ""
)

parse_currency(
  x,
  symbol = get_currency_symbol(x),
  digits = max(get_digits(x)),
  format = "f",
  big.mark = ",",
  ...
)

Arguments

x

a numeric vector.

symbol

currency symbol

digits

an integer to indicate the number of digits of the percentage string.

format

format type passed to formatC().

big.mark

thousands separator

...

additional parameters passed to formattable().

sep

separator between symbol and value

See also

Other numeric vectors: num_accounting(), num_comma(), num_digits(), num_percent(), num_scientific()

Examples

num_currency(200000)
#> [1] $200,000.00
num_currency(200000, "\U20AC")
#> [1] €200,000.00
num_currency(1200000, "USD", sep = " ")
#> [1] USD 1,200,000.00
num_currency(1200000, "USD", format = "d", sep = " ")
#> [1] USD 1,200,000
parse_currency("$ 120,250.50")
#> [1] $120,250.50
parse_currency("HK$ 120,250.50", symbol = "HK$")
#> [1] HK$120,250.50
parse_currency("HK$ 120, 250.50")
#> [1] HK$120,250.50