scales
scales copied to clipboard
feature requests: suppress trailing 0s when specifying accuracy and specify maximum number of digits when using NULL argument heuristic
I have an instance where I'm wanting to use scales::label_number and its variants to flexibly format different vectors that may change based on user feedback in an interactive environment.
Some of the vectors will require a high degree of specificity; others don't or are integers.
The current behavior of the functions are limiting in this case. For example:
vector <- c(12.4371849031094, 12.43629013859305, 3, 3, 300) scales::label_comma(accuracy = NULL)(vector) [1] "12.43718" "12.43629" "3.00000" "3.00000" "300.00000"
Isn't ideal, because the two values ~12.44 are very close, and 3 and 300 are far away. Maybe 1-2 decimals is appropriate.
But if I set the accuracy manually and the vector becomes different in the interactive session, I'll get trailing 0s that I don't want:
vector2 <- seq(100, 300, by = 50) scales::label_comma(accuracy = .001)(vector2) [1] "100.000" "150.000" "200.000" "250.000" "300.000"
I can think of some work arounds, but think it'd be great to be able to specify a maximum number of digits when using the heuristic without forcing the leading 0s!
Thank you!