Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature requests: suppress trailing 0s when specifying accuracy and specify maximum number of digits when using NULL argument heuristic #418

Open
kmcd39 opened this issue Jan 24, 2024 · 0 comments
Labels
feature a feature request or enhancement

Comments

@kmcd39
Copy link

kmcd39 commented Jan 24, 2024

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!

@thomasp85 thomasp85 added the feature a feature request or enhancement label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants