@@ -132,7 +132,7 @@ is_staged <- function(x) {
132
132
}
133
133
134
134
# Strip dots from expressions
135
- strip_dots <- function (expr , env ) {
135
+ strip_dots <- function (expr , env , strip_pronoun = FALSE ) {
136
136
if (is.atomic(expr )) {
137
137
expr
138
138
} else if (is.name(expr )) {
@@ -145,29 +145,29 @@ strip_dots <- function(expr, env) {
145
145
} else if (is_quosure(expr )) {
146
146
# strip dots from quosure and reconstruct the quosure
147
147
new_quosure(
148
- strip_dots(quo_get_expr(expr ), env = quo_get_env(expr )),
148
+ strip_dots(quo_get_expr(expr ), env = quo_get_env(expr ), strip_pronoun = strip_pronoun ),
149
149
quo_get_env(expr )
150
150
)
151
151
} else if (is.call(expr )) {
152
- if (is_call(expr , " $" ) && is_symbol(expr [[2 ]], " .data" )) {
153
- expr [[3 ]]
154
- } else if (is_call(expr , " [[" ) && is_symbol(expr [[2 ]], " .data" )) {
152
+ if (strip_pronoun && is_call(expr , " $" ) && is_symbol(expr [[2 ]], " .data" )) {
153
+ strip_dots( expr [[3 ]], env , strip_pronoun = strip_pronoun )
154
+ } else if (strip_pronoun && is_call(expr , " [[" ) && is_symbol(expr [[2 ]], " .data" )) {
155
155
tryCatch(
156
156
sym(eval(expr [[3 ]], env )),
157
157
error = function (e ) expr [[3 ]]
158
158
)
159
159
} else if (is_call(expr , " stat" )) {
160
- strip_dots(expr [[2 ]])
160
+ strip_dots(expr [[2 ]], env , strip_pronoun = strip_pronoun )
161
161
} else {
162
- expr [- 1 ] <- lapply(expr [- 1 ], strip_dots , env = env )
162
+ expr [- 1 ] <- lapply(expr [- 1 ], strip_dots , env = env , strip_pronoun = strip_pronoun )
163
163
expr
164
164
}
165
165
} else if (is.pairlist(expr )) {
166
166
# In the unlikely event of an anonymous function
167
- as.pairlist(lapply(expr , strip_dots , env = env ))
167
+ as.pairlist(lapply(expr , strip_dots , env = env , strip_pronoun = strip_pronoun ))
168
168
} else if (is.list(expr )) {
169
169
# For list of aesthetics
170
- lapply(expr , strip_dots , env = env )
170
+ lapply(expr , strip_dots , env = env , strip_pronoun = strip_pronoun )
171
171
} else {
172
172
abort(glue(" Unknown input: {class(expr)[1]}" ))
173
173
}
@@ -194,7 +194,7 @@ make_labels <- function(mapping) {
194
194
return (aesthetic )
195
195
}
196
196
mapping <- strip_stage(mapping )
197
- mapping <- strip_dots(mapping )
197
+ mapping <- strip_dots(mapping , strip_pronoun = TRUE )
198
198
if (is_quosure(mapping ) && quo_is_symbol(mapping )) {
199
199
name <- as_string(quo_get_expr(mapping ))
200
200
} else {
0 commit comments