Skip to content

Commit 6f6a8ba

Browse files
authored
#4173 lambda functions in discrete scales & facets (#4188)
1 parent 800c5b4 commit 6f6a8ba

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@
126126

127127
* The scale arguments `limits`, `breaks`, `minor_breaks`, `labels`, `rescaler`
128128
and `oob` now accept purrr style lambda notation (@teunbrand, #4427).
129+
130+
* `as_labeller()` (and therefore also `labeller()`) now handles functions in
131+
purrr-style lambda notation (@netique, #4188).
129132

130133
# ggplot2 3.3.3
131134
This is a small patch release mainly intended to address changes in R and CRAN.

R/labeller.r

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ as_labeller <- function(x, default = label_value, multi_line = TRUE) {
318318
x(labels)
319319
} else if (is.function(x)) {
320320
default(lapply(labels, x))
321+
} else if (is.formula(x)) {
322+
default(lapply(labels, as_function(x)))
321323
} else if (is.character(x)) {
322324
default(lapply(labels, function(label) x[label]))
323325
} else {

0 commit comments

Comments
 (0)