Skip to contents

[Deprecated]

smart_digits() and smart_digits_format() are deprecated. Use scales::label_number(), which also picks the accuracy from the smallest gap between values.

Usage

smart_digits(x, ...)

smart_digits_format(x, ...)

Arguments

x

A numeric vector to format.

...

Parameters passed to base::format().

Value

A character vector. smart_digits_format() returns a function with a single argument x, a numeric vector, that returns a character vector.

Author

Josh O'Brien, Baptiste Auguie, Jeffrey B. Arnold

Examples

# Use scales::label_number() instead
scales::label_number()(c(0.1234, 0.5, 1.25))
#> [1] "0.12" "0.50" "1.25"

library(ggplot2)

ggplot(mtcars, aes(x = wt, y = mpg)) +
  geom_point() +
  scale_y_continuous(labels = scales::label_number())