Let’s make a simple gt table from the exibble dataset. We’ll keep only the num and currency, columns, then, format those columns using fmt_currency() (with the "JPY" and "GBP" currencies).
Let’s take a single column from exibble (currency) and format it with a currency name (this differs from the 3-letter currency code). In this case, we’ll use the "euro" currency and set the placement of the symbol to the right of any value. Additionally, the currency symbol will separated from the value with a single space character (using incl_space = TRUE).
With the pizzaplace dataset, let’s make a summary table that gets the number of "hawaiian" pizzas sold (and revenue generated) by month. In the gt table, we’ll format only the revenue column. The currency value is automatically U.S. Dollars when don’t supply either a currency code or a locale. We’ll also create a grand summary with grand_summary_rows(). Within that summary row, the total revenue needs to be formatted with fmt_currency() and we can do that within the fmt argument.
If supplying a locale value to fmt_currency(), we can opt use the locale’s assumed currency and not have to supply a currency value (doing so would override the locale’s default currency). With a column of locale values, we can format currency values on a row-by-row basis through the use of from_column(). Here, we’ll reference the locale column in the argument of the same name.
We can similarly use from_column() to reference a column that has currency code values. Here’s an example of how to create a simple currency conversion table. The curr column contains the 3-letter currency codes, and that column is referenced via from_column() in the currency argument of fmt_currency().