gbp: Write a monetary value

View source: R/utils.R

gbpR Documentation

Write a monetary value

Description

Formats a number, or list of numbers, into currency.

Usage

gbp(x, p = FALSE, char = TRUE)

Arguments

x

Monetary value, or list of values

p

Logical; if TRUE show value to nearest penny, cent etc. If FALSE show it to the nearest pound, dollar, euro etc.

char

Logical; if TRUE format the currency values into a character vector, with pretty printing, including comma separators for thousands, otherwise convert to rounded numeric values.

Details

If x is defined using the c() operator and contains one or more character elements, all elements of x will be coerced to characters, and this function will return "NA" for all elements. It is safer to define x as a list, in which all non-numeric elements will be translated to "NA".

Value

A character vector with pretty formatted currency values (if char is TRUE), or a vector of rounded numeric values.


rdecision documentation built on April 3, 2025, 6:09 p.m.