to_currency: Format numeric or integer values as currency values

Description Usage Arguments Examples

View source: R/reformat.R

Description

a formatter that lets you take numeric or integer values (12000) and convert them to strings that are currency-formatted ($12,000). Full control is available over the currency symbol, the size of delimited groups, the sign used to delimit groups, and decimal placement.

Usage

1
2
3
to_currency(x, currency_symbol = "£", symbol_first = TRUE,
  group_size = 3, group_delim = ",", decimal_size = 2,
  decimal_delim = ".")

Arguments

x

a numeric or integer vector containing values you want to currency-ify

currency_symbol

the symbol that identifies the currency. "£" by default.

symbol_first

whether the symbol goes at the beginning (TRUE) or end (FALSE) of the generated value. TRUE by default.

group_size

the size of delimited groups (2, 3, or 4 digits, say). Set to 3 by default.

group_delim

the delimiter for each group.

decimal_size

the number of digits after the decimal place. 2 by default but can be more (the Japanese Yen, for example, can go down to one rin, which is a thousandth of a Yen).

decimal_delim

the delimiter to use for sub-unit, decimal values. A period by default.

Examples

1
2
to_currency(120000.03)
#[1] "£120,000.03"

KevinPedroza/lucr documentation built on Dec. 2, 2019, 12:03 a.m.