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 request: Could a breaks_equal function be provided? #438

Open
davidhodge931 opened this issue Jun 14, 2024 · 2 comments
Open

Feature request: Could a breaks_equal function be provided? #438

davidhodge931 opened this issue Jun 14, 2024 · 2 comments
Labels
feature a feature request or enhancement

Comments

@davidhodge931
Copy link

It'd be useful to have a function to split a scale into breaks of equal size from the limits.

I thought maybe it might like it scales::breaks_equal(n = NULL, ....)

Below is the output that it would generate in breaks as a demo for different n's for a example limits of c(0, 10), but rounded sensibly.

x1 <- 0
x2 <- 10

n <- 2
seq(from = x1, to = x2, by = (x2 - x1) / (n - 1))
#> [1]  0 10
n <- 3
seq(from = x1, to = x2, by = (x2 - x1) / (n - 1))
#> [1]  0  5 10
n <- 4
seq(from = x1, to = x2, by = (x2 - x1) / (n - 1))
#> [1]  0.000000  3.333333  6.666667 10.000000
n <- 5
seq(from = x1, to = x2, by = (x2 - x1) / (n - 1))
#> [1]  0.0  2.5  5.0  7.5 10.0
n <- 6
seq(from = x1, to = x2, by = (x2 - x1) / (n - 1))
#> [1]  0  2  4  6  8 10

Created on 2024-06-15 with reprex v2.1.0

@davidhodge931
Copy link
Author

Also, be great if this could work with Date's etc

@davidhodge931 davidhodge931 changed the title Could a breaks_equal function be provided? Feature request: Could a breaks_equal function be provided? Jul 21, 2024
@teunbrand
Copy link
Contributor

Are you think of the seq(length.out) argument, or is it somewhat more complex than this?

@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

3 participants