format: Printing currency values or percentages

format_currencyR Documentation

Printing currency values or percentages

Description

Wrapper functions for printing nicely formatted values.

Usage

format_currency(
  x,
  prefix = "",
  suffix = "",
  big.mark = ",",
  accuracy = NULL,
  min_length = NULL,
  ...
)

format_percent(x, accuracy = 0.1, ...)

Arguments

x

A numeric vector

prefix, suffix

Symbols to display before and after value.

big.mark

Character used between every 3 digits to separate thousands. The default (NULL) retrieves the setting from the number options.

accuracy

A number to round to. Use (e.g.) 0.01 to show 2 decimal places of precision. If NULL, the default, uses a heuristic that should ensure breaks have the minimum number of digits needed to show the difference between adjacent values.

Applied to rescaled data.

min_length

A numeric. Minimum number of characters of the string with the formatted value.

...

Other arguments passed on to base::format().

Value

A character. Formatted value.

A character. Formatted value.

See Also

scales::dollar()

scales::percent()

Examples

format_currency(2345678, suffix = " PLN")
format_percent(0.52366)

R4GoodPersonalFinances documentation built on June 8, 2025, 11:18 a.m.