Skip to content

Use .ignore_empty="all" for enquos() #2936

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

Merged
Merged
6 changes: 2 additions & 4 deletions R/aes.r
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ NULL
#' cut3 <- function(x) cut_number(x, 3)
#' scatter_by(mtcars, cut3(disp), drat)
aes <- function(x, y, ...) {
exprs <- rlang::enquos(x = x, y = y, ...)
is_missing <- vapply(exprs, rlang::quo_is_missing, logical(1))

aes <- new_aes(exprs[!is_missing], env = parent.frame())
exprs <- rlang::enquos(x = x, y = y, ..., .ignore_empty = "all")
aes <- new_aes(exprs, env = parent.frame())
rename_aes(aes)
}

Expand Down
12 changes: 3 additions & 9 deletions R/quick-plot.r
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,13 @@ qplot <- function(x, y, ..., data, facets = NULL, margins = FALSE,
if (!missing(position)) warning("`position` is deprecated", call. = FALSE)
if (!is.character(geom)) stop("`geom` must be a character vector", call. = FALSE)

exprs <- rlang::enquos(x = x, y = y, ...)
is_missing <- vapply(exprs, rlang::quo_is_missing, logical(1))
exprs <- rlang::enquos(x = x, y = y, ..., .ignore_empty = "all")
# treat arguments as regular parameters if they are wrapped into I() or
# if they don't have a name that is in the list of all aesthetics
is_constant <- (!names(exprs) %in% ggplot_global$all_aesthetics) |
vapply(exprs, rlang::quo_is_call, logical(1), name = "I")

mapping <- new_aes(exprs[!is_missing & !is_constant], env = parent.frame())
mapping <- new_aes(exprs[!is_constant], env = parent.frame())

consts <- exprs[is_constant]

Expand All @@ -90,12 +89,7 @@ qplot <- function(x, y, ..., data, facets = NULL, margins = FALSE,
xlab <- rlang::quo_name(exprs$x)
}
if (is.null(ylab)) {
# Work around quo_name() bug: https://github.com/r-lib/rlang/issues/430
if (rlang::quo_is_null(exprs$y)) {
ylab <- "NULL"
} else {
ylab <- rlang::quo_name(exprs$y)
}
ylab <- rlang::quo_name(exprs$y)
}

if (missing(data)) {
Expand Down