Skip to content

Commit

Permalink
Make close_end implicit in ... in chop_n(), chop_equally() an…
Browse files Browse the repository at this point in the history
…d `chop_evenly()`.

The default has changed to `close_end = TRUE` anyway.
  • Loading branch information
hughjonesd committed Jun 10, 2024
1 parent 4457b6e commit 28693ac
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 29 deletions.
13 changes: 5 additions & 8 deletions R/chop-by-group-size.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,28 @@ chop_deciles <- function(x, ...) {
#' elements, you may get fewer `groups` than requested. If so, a warning will
#' be emitted. See the examples.
#'
#'
#'
#' @family chopping functions
#'
#' @export
#' @order 1
#' @examples
#' chop_equally(1:10, 5)
#'
#' # You can't always guarantee `groups` groups:
#' # You can't always guarantee equal-sized groups:
#' dupes <- c(1, 1, 1, 2, 3, 4, 4, 4)
#' quantile(dupes, 0:4/4)
#' chop_equally(dupes, 4)
#' # Or as many groups as you ask for:
#' chop_equally(c(1, 1, 2, 2), 3)
chop_equally <- function (
x,
groups,
...,
labels = lbl_intervals(),
left = is.numeric(x),
close_end = TRUE,
raw = TRUE
) {
chop(x, brk_equally(groups), ..., labels = labels, left = left,
close_end = close_end, raw = raw)
chop(x, brk_equally(groups), ..., labels = labels, left = left, raw = raw)
}


Expand Down Expand Up @@ -159,10 +157,9 @@ chop_n <- function (
x,
n,
...,
close_end = TRUE,
tail = "split"
) {
res <- chop(x, brk_n(n, tail = tail), ..., close_end = close_end)
res <- chop(x, brk_n(n, tail = tail), ...)
if (tail == "split" && max(tabulate(res)) > n) {
warning("Some intervals contain more than ", n, " elements")
}
Expand Down
7 changes: 2 additions & 5 deletions R/chop-by-width.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ chop_width <- function (
#' @inheritParams chop
#' @inherit chop-doc params return
#'
#' @details `chop_evenly()` sets `close_end = TRUE` by default.
#'
#' @family chopping functions
#'
#' @export
Expand All @@ -59,10 +57,9 @@ chop_width <- function (
chop_evenly <- function (
x,
intervals,
...,
close_end = TRUE
...
) {
chop(x, brk_evenly(intervals), ..., close_end = close_end)
chop(x, brk_evenly(intervals), ...)
}


Expand Down
8 changes: 3 additions & 5 deletions man/chop_equally.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions man/chop_evenly.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions man/chop_n.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 28693ac

Please sign in to comment.