Skip to content

Commit 653410f

Browse files
committed
allow lambda notation for breaks/binwidth/bins
1 parent eb80474 commit 653410f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

R/bin.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ compute_bins <- function(x, scale = NULL, breaks = NULL, binwidth = NULL, bins =
124124
check_length(range, 2L)
125125

126126
if (!is.null(breaks)) {
127+
breaks <- allow_lambda(breaks)
127128
if (is.function(breaks)) {
128129
breaks <- breaks(x)
129130
}
@@ -142,6 +143,7 @@ compute_bins <- function(x, scale = NULL, breaks = NULL, binwidth = NULL, bins =
142143
}
143144

144145
if (!is.null(binwidth)) {
146+
binwidth <- allow_lambda(binwidth)
145147
if (is.function(binwidth)) {
146148
binwidth <- binwidth(x)
147149
}
@@ -153,6 +155,7 @@ compute_bins <- function(x, scale = NULL, breaks = NULL, binwidth = NULL, bins =
153155
return(bins)
154156
}
155157

158+
bins <- allow_lambda(bins)
156159
if (is.function(bins)) {
157160
bins <- bins(x)
158161
}

0 commit comments

Comments
 (0)