Skip to content

Commit 92cea24

Browse files
committed
Fix aes_q bug. Add more examples
1 parent 4c1e6ad commit 92cea24

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

R/aes.r

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ is_position_aes <- function(vars) {
100100
#' aes(mpg, wt, col = cyl, fill = NULL)
101101
#' aes_string("mpg", "wt", col = "cyl", fill = NULL)
102102
#' aes_q(quote(mpg), quote(wt), col = quote(cyl), fill = NULL)
103+
#'
104+
#' aes(col = cyl, fill = NULL)
105+
#' aes_string(col = "cyl", fill = NULL)
106+
#' aes_q(col = quote(cyl), fill = NULL)
103107
aes_string <- function(x = NULL, y = NULL, ...) {
104108
mapping <- c(compact(list(x = x, y = y)), list(...))
105109
mapping[vapply(mapping, is.null, logical(1))] <- "NULL"
@@ -110,8 +114,8 @@ aes_string <- function(x = NULL, y = NULL, ...) {
110114

111115
#' @rdname aes_string
112116
#' @export
113-
aes_q <- function(x, y, ...) {
114-
mapping <- list(x = x, y = y, ...)
117+
aes_q <- function(x = NULL, y = NULL, ...) {
118+
mapping <- c(compact(list(x = x, y = y)), list(...))
115119
structure(rename_aes(mapping), class = "uneval")
116120
}
117121

man/aes_string.Rd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
\usage{
77
aes_string(x = NULL, y = NULL, ...)
88

9-
aes_q(x, y, ...)
9+
aes_q(x = NULL, y = NULL, ...)
1010
}
1111
\arguments{
1212
\item{x,y,...}{List of name value pairs}
@@ -28,6 +28,10 @@ names/calls to define the aesthetic mappings, rather than having to use
2828
aes(mpg, wt, col = cyl, fill = NULL)
2929
aes_string("mpg", "wt", col = "cyl", fill = NULL)
3030
aes_q(quote(mpg), quote(wt), col = quote(cyl), fill = NULL)
31+
32+
aes(col = cyl, fill = NULL)
33+
aes_string(col = "cyl", fill = NULL)
34+
aes_q(col = quote(cyl), fill = NULL)
3135
}
3236
\seealso{
3337
\code{\link{aes}}

0 commit comments

Comments
 (0)