Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

currency

Supply a custom currency symbol to fmt_currency()


Description

The currency() helper function makes it easy to specify a context-aware currency symbol to currency argument of fmt_currency(). Since gt can render tables to several output formats, currency() allows for different variations of the custom symbol based on the output context (which are html, latex, rtf, and default). The number of decimal places for the custom currency defaults to 2, however, a value set for the decimals argument of fmt_currency() will take precedence.

Usage

currency(..., .list = list2(...))

Arguments

...

One or more named arguments using output contexts as the names and currency symbol text as the values.

.list

Allows for the use of a list as an input alternative to ....

Details

We can use any combination of html, latex, rtf, and default as named arguments for the currency text in each of the namesake contexts. The default value is used as a fallback when there doesn't exist a dedicated currency text value for a particular output context (e.g., when a table is rendered as HTML and we use currency(latex = "LTC", default = "ltc"), the currency symbol will be "ltc". For convenience, if we provide only a single string without a name, it will be taken as the default (i.e., currency("ltc") is equivalent to currency(default = "ltc")). However, if we were to specify currency strings for multiple output contexts, names are required each and every context.

Value

A list object of class gt_currency.

Figures

Function ID

7-14

See Also

Examples

# Use `exibble` to create a gt table;
# format the `currency` column to have
# currency values in guilder (a defunct
# Dutch currency)
tab_1 <-
  exibble %>%
  gt() %>%
  fmt_currency(
    columns = vars(currency),
    currency = currency(
      html = "&fnof;",
      default = "f"),
    decimals = 2
  )

gt

Easily Create Presentation-Ready Display Tables

v0.2.2
MIT + file LICENSE
Authors
Richard Iannone [aut, cre] (<https://orcid.org/0000-0003-3925-190X>), Joe Cheng [aut], Barret Schloerke [aut] (<https://orcid.org/0000-0001-9986-114X>), RStudio [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.