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

number(accuracy = NULL) heuristic too precise? #279

Closed
nicolaspayette opened this issue Jun 15, 2020 · 2 comments · Fixed by #304
Closed

number(accuracy = NULL) heuristic too precise? #279

nicolaspayette opened this issue Jun 15, 2020 · 2 comments · Fixed by #304

Comments

@nicolaspayette
Copy link

scales::number(c(10, 20, 30))
#> [1] "10" "20" "30"
scales::number(c(5, 10, 15))
#> [1] "5.0"  "10.0" "15.0"

When the smallest interval is >= 1 and < 10, the heuristic computes an accuracy of 0.1.

This might be the intended behaviour, but I find it puzzling: why would the extra decimal be desirable?

The question has been raised in passing before, but I didn't find any other discussion.

If this behaviour is modified, it might also make sense to change the default in label_number_si() to accuracy = NULL, since the current default of accuracy = 1 gives results like:

scales::label_number_si()(c(1.5E6, 2E6, 2.5E6))
#> [1] "2M" "2M" "2M"
@davidchall
Copy link
Contributor

@nicolaspayette - Please note that #235 changes the default of label_number_si() to accuracy = NULL.

@nicolaspayette
Copy link
Author

nicolaspayette commented Mar 26, 2021

@davidchall, #235 looks fantastic. And maybe having accuracy = NULL as a default will bring more attention to the present issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants