A set of functions to format numeric values:

  • number_format() and number() are generic formatters for numbers.

  • comma_format() and comma() format numbers with commas separating thousands.

  • percent_format() and percent() multiply values by one hundred and display percent sign.

All formatters allow you to re-scale (multiplicatively), to round to specified accuracy, to add custom suffix and prefix and to specify decimal.mark and big.mark.

number_format(accuracy = NULL, scale = 1, prefix = "", suffix = "",
  big.mark = " ", decimal.mark = ".", trim = TRUE, ...)

number(x, accuracy = NULL, scale = 1, prefix = "", suffix = "",
  big.mark = " ", decimal.mark = ".", trim = TRUE, ...)

comma_format(accuracy = NULL, scale = 1, prefix = "", suffix = "",
  big.mark = ",", decimal.mark = ".", trim = TRUE, digits, ...)

comma(x, accuracy = NULL, scale = 1, prefix = "", suffix = "",
  big.mark = ",", decimal.mark = ".", trim = TRUE, digits, ...)

percent_format(accuracy = NULL, scale = 100, prefix = "",
  suffix = "%", big.mark = " ", decimal.mark = ".", trim = TRUE,
  ...)

percent(x, accuracy = NULL, scale = 100, prefix = "",
  suffix = "%", big.mark = " ", decimal.mark = ".", trim = TRUE,
  ...)

Arguments

accuracy

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.

scale

A scaling factor: x will be multiply by scale before formating (useful if the underlying data is on another scale, e.g. for computing percentages or thousands).

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 FALSE, values are right-justified to a common width (see base::format()).

...

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

x

A numeric vector to format.

digits

Deprecated, use accuracy instead.

Value

*_format() returns a function with single parameter x, a numeric vector, that returns a character vector.

Examples

demo_continuous(c(-1e6, 1e6))
#> ggplot(df, aes(x, 1)) + #> geom_blank() + #> scale_x_continuous()
# Suppress scientific notation with number_format() demo_continuous(c(-1e6, 1e6), labels = number_format())
#> ggplot(df, aes(x, 1)) + #> geom_blank() + #> scale_x_continuous(labels = number_format())
# Or comma_format() demo_continuous(c(-1e6, 1e6), labels = comma_format())
#> ggplot(df, aes(x, 1)) + #> geom_blank() + #> scale_x_continuous(labels = comma_format())
# Display currencies with dollar_format() demo_continuous(c(-1e6, 1e6), labels = dollar_format())
#> ggplot(df, aes(x, 1)) + #> geom_blank() + #> scale_x_continuous(labels = dollar_format())
demo_continuous(c(-1e6, 1e6), labels = dollar_format(prefix = "\u20ac"))
#> ggplot(df, aes(x, 1)) + #> geom_blank() + #> scale_x_continuous(labels = dollar_format(prefix = "€"))
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '-€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€0' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€500,000' in 'mbcsToSbcs': dot substituted for <ac>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <e2>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <82>
#> Warning: conversion failure on '€1,000,000' in 'mbcsToSbcs': dot substituted for <ac>
# Rescale using the scale parameter demo_continuous(c(-1e6, 1e6), labels = dollar_format(scale = 1 / 1000))
#> ggplot(df, aes(x, 1)) + #> geom_blank() + #> scale_x_continuous(labels = dollar_format(scale = 1/1000))
# Show percentages with percent_format() demo_continuous(c(0, 1))
#> ggplot(df, aes(x, 1)) + #> geom_blank() + #> scale_x_continuous()
# Or convert to percentage: demo_continuous(c(0, 1), labels = percent_format())
#> ggplot(df, aes(x, 1)) + #> geom_blank() + #> scale_x_continuous(labels = percent_format())
# Or use prefix and suffix to create your own french_percent <- number_format( accuracy = NULL, scale = 100, decimal.mark = ",", suffix = " %" ) demo_continuous(c(0, .01), labels = french_percent)
#> ggplot(df, aes(x, 1)) + #> geom_blank() + #> scale_x_continuous(labels = french_percent)