-
Notifications
You must be signed in to change notification settings - Fork 2.1k
#4173 lambda functions in discrete scales & facets #4188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
f16a15b
5331072
ce15ec1
05167de
019c43d
6d488b6
7cf02ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -318,6 +318,8 @@ as_labeller <- function(x, default = label_value, multi_line = TRUE) { | |
| x(labels) | ||
| } else if (is.function(x)) { | ||
| default(lapply(labels, x)) | ||
| } else if (is.formula(x)) { | ||
| default(lapply(labels, as_function(x))) | ||
| } else if (is.character(x)) { | ||
| default(lapply(labels, function(label) x[label])) | ||
| } else { | ||
|
|
@@ -433,7 +435,10 @@ labeller <- function(..., .rows = NULL, .cols = NULL, | |
| if (!is.null(keep.as.numeric)) { | ||
| .Deprecated(old = "keep.as.numeric") | ||
| } | ||
|
|
||
| dots <- list(...) | ||
|
|
||
|
|
||
|
||
| .default <- as_labeller(.default) | ||
|
|
||
| function(labels) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -184,6 +184,7 @@ discrete_scale <- function(aesthetics, scale_name, palette, name = waiver(), | |
|
|
||
| check_breaks_labels(breaks, labels) | ||
|
|
||
| if (is.formula(labels)) labels <- as_function(labels) | ||
|
||
| # Convert formula input to function if appropriate | ||
| limits <- allow_lambda(limits) | ||
| breaks <- allow_lambda(breaks) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.