currency | R Documentation |
Transform input to a currency. The actual values are numeric, but will be printed as formatted currency values.
as.currency(x, currency_symbol = Sys.localeconv()["int_curr_symbol"], ...) is.currency(x) ## S3 method for class 'currency' print( x, decimal.mark = getOption("OutDec"), big.mark = ifelse(decimal.mark == ",", ".", ","), as_symbol = FALSE, ... ) ## S3 method for class 'currency' format( x, currency_symbol = attributes(x)$currency_symbol, decimal.mark = getOption("OutDec"), big.mark = ifelse(decimal.mark == ",", ".", ","), as_symbol = FALSE, ... )
x |
input |
currency_symbol |
the currency symbol to use, which defaults to the current system locale setting (see |
... |
other parameters passed on to methods |
decimal.mark |
symbol to use as a decimal separator, defaults to |
big.mark |
symbol to use as a thousands separator, defaults to a dot if |
as_symbol |
try to format and print using currency symbols instead of text |
Printing currency will always have a currency symbol followed by a space, 2 decimal places and is never written in scientific format (like 2.5e+04).
money <- as.currency(c(0.25, 2.5, 25, 25000)) money sum(money) max(money) mean(money) format(money, currency_symbol = "USD") format(money, currency_symbol = "EUR", decimal.mark = ",") format(money, currency_symbol = "EUR", as_symbol = TRUE) as.currency(2.5e+04)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.