|
26 | 26 | #' or left edges of bins are included in the bin. |
27 | 27 | #' @param pad If `TRUE`, adds empty bins at either end of x. This ensures |
28 | 28 | #' frequency polygons touch 0. Defaults to `FALSE`. |
29 | | -#' @param drop Treatment of zero count bins. If `"all"` (default), such |
30 | | -#' bins are kept as-is. If `"none"`, all zero count bins are filtered out. |
31 | | -#' If `"inner"` only zero count bins at the flanks are filtered out, but not |
32 | | -#' in the middle. `TRUE` is shorthand for `"all"` and `FALSE` is shorthand |
| 29 | +#' @param drop Treatment of zero count bins. If `"none"` (default), such |
| 30 | +#' bins are kept as-is. If `"all"`, all zero count bins are filtered out. |
| 31 | +#' If `"extremes"` only zero count bins at the flanks are filtered out, but |
| 32 | +#' not in the middle. `TRUE` is shorthand for `"all"` and `FALSE` is shorthand |
33 | 33 | #' for `"none"`. |
34 | 34 | #' @eval rd_computed_vars( |
35 | 35 | #' count = "number of points in bin.", |
@@ -100,9 +100,10 @@ StatBin <- ggproto("StatBin", Stat, |
100 | 100 | if (is.logical(params$drop)) { |
101 | 101 | params$drop <- if (isTRUE(params$drop)) "all" else "none" |
102 | 102 | } |
| 103 | + drop <- params$drop |
103 | 104 | params$drop <- arg_match0( |
104 | | - params$drop %||% "all", |
105 | | - c("all", "none", "inner"), arg_nm = "drop" |
| 105 | + params$drop %||% "none", |
| 106 | + c("all", "none", "extremes"), arg_nm = "drop" |
106 | 107 | ) |
107 | 108 |
|
108 | 109 | has_x <- !(is.null(data$x) && is.null(params$x)) |
@@ -146,8 +147,8 @@ StatBin <- ggproto("StatBin", Stat, |
146 | 147 |
|
147 | 148 | keep <- switch( |
148 | 149 | drop, |
149 | | - none = bins$count != 0, |
150 | | - inner = inner_runs(bins$count != 0), |
| 150 | + all = bins$count != 0, |
| 151 | + extremes = inner_runs(bins$count != 0), |
151 | 152 | TRUE |
152 | 153 | ) |
153 | 154 | bins <- vec_slice(bins, keep) |
|
0 commit comments