@@ -132,7 +132,7 @@ is_staged <- function(x) {
132132}
133133
134134# Strip dots from expressions
135- strip_dots <- function (expr , env ) {
135+ strip_dots <- function (expr , env , strip_pronoun = FALSE ) {
136136 if (is.atomic(expr )) {
137137 expr
138138 } else if (is.name(expr )) {
@@ -145,29 +145,29 @@ strip_dots <- function(expr, env) {
145145 } else if (is_quosure(expr )) {
146146 # strip dots from quosure and reconstruct the quosure
147147 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 ),
149149 quo_get_env(expr )
150150 )
151151 } 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" )) {
155155 tryCatch(
156156 sym(eval(expr [[3 ]], env )),
157157 error = function (e ) expr [[3 ]]
158158 )
159159 } else if (is_call(expr , " stat" )) {
160- strip_dots(expr [[2 ]])
160+ strip_dots(expr [[2 ]], env , strip_pronoun = strip_pronoun )
161161 } 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 )
163163 expr
164164 }
165165 } else if (is.pairlist(expr )) {
166166 # 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 ))
168168 } else if (is.list(expr )) {
169169 # For list of aesthetics
170- lapply(expr , strip_dots , env = env )
170+ lapply(expr , strip_dots , env = env , strip_pronoun = strip_pronoun )
171171 } else {
172172 abort(glue(" Unknown input: {class(expr)[1]}" ))
173173 }
@@ -194,7 +194,7 @@ make_labels <- function(mapping) {
194194 return (aesthetic )
195195 }
196196 mapping <- strip_stage(mapping )
197- mapping <- strip_dots(mapping )
197+ mapping <- strip_dots(mapping , strip_pronoun = TRUE )
198198 if (is_quosure(mapping ) && quo_is_symbol(mapping )) {
199199 name <- as_string(quo_get_expr(mapping ))
200200 } else {
0 commit comments