Skip to content

Commit 5d9cb8b

Browse files
cdervthomasp85
authored andcommitted
Add ... to cut width to pass to cut.default (#3238)
1 parent 0a6f2fb commit 5d9cb8b

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ core developer team.
5050

5151
## Minor improvements and bug fixes
5252

53+
* `cut_width()` now accepts `...` to pass further arguments to `base::cut.default()`
54+
like `cut_number()` and `cut_interval()` already did (@cderv, #3055)
55+
5356
* `coord_map()` now can have axes on the top and right (@karawoo, #3042).
5457

5558
* `coord_sf()`, `coord_map()`, and `coord_polar()` now squash `-Inf` and `Inf`

R/utilities-break.r

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#' table(cut_width(runif(1000), 0.1))
2121
#' table(cut_width(runif(1000), 0.1, boundary = 0))
2222
#' table(cut_width(runif(1000), 0.1, center = 0))
23+
#' table(cut_width(runif(1000), 0.1, labels = FALSE))
2324
cut_interval <- function(x, n = NULL, length = NULL, ...) {
2425
cut(x, breaks(x, "width", n, length), include.lowest = TRUE, ...)
2526
}
@@ -46,7 +47,7 @@ cut_number <- function(x, n = NULL, ...) {
4647
#' `boundary = 0.5`.
4748
#' @param closed One of `"right"` or `"left"` indicating whether right
4849
#' or left edges of bins are included in the bin.
49-
cut_width <- function(x, width, center = NULL, boundary = NULL, closed = c("right", "left")) {
50+
cut_width <- function(x, width, center = NULL, boundary = NULL, closed = c("right", "left"), ...) {
5051
x <- as.numeric(x)
5152
width <- as.numeric(width)
5253

@@ -80,7 +81,7 @@ cut_width <- function(x, width, center = NULL, boundary = NULL, closed = c("righ
8081
max_x <- max(x, na.rm = TRUE) + (1 - 1e-08) * width
8182

8283
breaks <- seq(min_x, max_x, width)
83-
cut(x, breaks, include.lowest = TRUE, right = (closed == "right"))
84+
cut(x, breaks, include.lowest = TRUE, right = (closed == "right"), ...)
8485
}
8586

8687
# Find the left side of left-most bin

man/cut_interval.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)