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.",
@@ -60,7 +60,7 @@ stat_bin <- function(mapping = NULL, data = NULL,
60
60
closed = c(" right" , " left" ),
61
61
pad = FALSE ,
62
62
na.rm = FALSE ,
63
- drop = " all " ,
63
+ drop = " none " ,
64
64
orientation = NA ,
65
65
show.legend = NA ,
66
66
inherit.aes = TRUE ) {
@@ -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 ))
@@ -132,7 +133,7 @@ StatBin <- ggproto("StatBin", Stat,
132
133
compute_group = function (data , scales , binwidth = NULL , bins = NULL ,
133
134
center = NULL , boundary = NULL ,
134
135
closed = c(" right" , " left" ), pad = FALSE ,
135
- breaks = NULL , flipped_aes = FALSE , drop = " all " ,
136
+ breaks = NULL , flipped_aes = FALSE , drop = " none " ,
136
137
# The following arguments are not used, but must
137
138
# be listed so parameters are computed correctly
138
139
origin = NULL , right = NULL ) {
@@ -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