Skip to contents

Set money formatter

Usage

set_formatter_money(
  widget,
  columns,
  decimal = c(",", "."),
  thousand = c(".", ","),
  symbol = "$",
  symbol_after = "p",
  negative_sign = "-",
  precision = FALSE,
  hoz_align = "left"
)

Arguments

widget

A tabulator() HTML widget.

columns

The names of the columns the formatter is applied to.

decimal

(character): Symbol to represent the decimal point.

thousand

(character, bool): Symbol to represent the thousands separator. Set to FALSE to disable the separator.

symbol

(character): The currency symbol.

symbol_after

(bool): Whether to put the symbol after the number.

negative_sign

(character, bool): The sign to show in front of the number. Set to TRUE causes negative numbers to be enclosed in brackets (123.45), which is the standard style for negative numbers in accounting.

precision

(integer, bool): The number of decimals to display. Set to FALSE to display all decimals that are provided.

hoz_align

(character): The horizontal alignment of the column.

Value

The updated tabulator() HTML widget

Examples

data <- data.frame(
  Account_Number = c(
    123456,
    345667,
    234567,
    234566
  ),
  Account_Balance = c(100, -50, 200.30, -21.5)
)

tabulator(data) |>
  set_formatter_money(
    "Account_Balance",
    symbol = "\U20AC",
    symbol_after = FALSE,
    hoz_align = "right"
  )