Label currencies ($100, $2.50, etc)
Format numbers as currency, rounding values to dollars or cents using a convenient heuristic.
label_dollar( accuracy = NULL, scale = 1, prefix = "$", suffix = "", big.mark = ",", decimal.mark = ".", trim = TRUE, largest_with_cents = 1e+05, negative_parens = FALSE, ... ) dollar_format( accuracy = NULL, scale = 1, prefix = "$", suffix = "", big.mark = ",", decimal.mark = ".", trim = TRUE, largest_with_cents = 1e+05, negative_parens = FALSE, ... ) dollar( x, accuracy = NULL, scale = 1, prefix = "$", suffix = "", big.mark = ",", decimal.mark = ".", trim = TRUE, largest_with_cents = 1e+05, negative_parens = FALSE, ... )
accuracy, largest_with_cents |
Number to round to. If |
scale |
A scaling factor: |
prefix, suffix |
Symbols to display before and after value. |
big.mark |
Character used between every 3 digits to separate thousands. |
decimal.mark |
The character to be used to indicate the numeric decimal point. |
trim |
Logical, if |
negative_parens |
Display negative using parentheses? |
... |
Other arguments passed on to |
x |
A numeric vector |
All label_()
functions return a "labelling" function, i.e. a function that
takes a vector x
and returns a character vector of length(x)
giving a
label for each input value.
Labelling functions are designed to be used with the labels
argument of
ggplot2 scales. The examples demonstrate their use with x scales, but
they work similarly for all scales, including those that generate legends
rather than axes.
dollar()
and format_dollar()
are retired; please use label_dollar()
instead.
Other labels for continuous scales:
label_bytes()
,
label_number_auto()
,
label_number_si()
,
label_ordinal()
,
label_parse()
,
label_percent()
,
label_pvalue()
,
label_scientific()
demo_continuous(c(0, 1), labels = label_dollar()) demo_continuous(c(1, 100), labels = label_dollar()) # Customise currency display with prefix and suffix demo_continuous(c(1, 100), labels = label_dollar(prefix = "USD ")) euro <- dollar_format( prefix = "", suffix = "\u20ac", big.mark = ".", decimal.mark = "," ) demo_continuous(c(1000, 1100), labels = euro) # Use negative_parens = TRUE for finance style display demo_continuous(c(-100, 100), labels = label_dollar(negative_parens = TRUE))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.