@@ -102,7 +102,9 @@ new_aesthetic <- function(x, env = globalenv()) {
102
102
x
103
103
}
104
104
new_aes <- function (x , env = globalenv()) {
105
- stopifnot(is.list(x ))
105
+ if (! is.list(x )) {
106
+ abort(" `x` must be a list" )
107
+ }
106
108
x <- lapply(x , new_aesthetic , env = env )
107
109
structure(x , class = " uneval" )
108
110
}
@@ -168,9 +170,7 @@ rename_aes <- function(x) {
168
170
duplicated_names <- names(x )[duplicated(names(x ))]
169
171
if (length(duplicated_names ) > 0L ) {
170
172
duplicated_message <- paste0(unique(duplicated_names ), collapse = " , " )
171
- warning(
172
- " Duplicated aesthetics after name standardisation: " , duplicated_message , call. = FALSE
173
- )
173
+ warn(glue(" Duplicated aesthetics after name standardisation: {duplicated_message}" ))
174
174
}
175
175
x
176
176
}
@@ -270,8 +270,7 @@ aes_ <- function(x, y, ...) {
270
270
} else if (is.call(x ) || is.name(x ) || is.atomic(x )) {
271
271
new_aesthetic(x , caller_env )
272
272
} else {
273
- stop(" Aesthetic must be a one-sided formula, call, name, or constant." ,
274
- call. = FALSE )
273
+ abort(" Aesthetic must be a one-sided formula, call, name, or constant." )
275
274
}
276
275
}
277
276
mapping <- lapply(mapping , as_quosure_aes )
@@ -327,11 +326,11 @@ aes_all <- function(vars) {
327
326
# ' @keywords internal
328
327
# ' @export
329
328
aes_auto <- function (data = NULL , ... ) {
330
- warning (" aes_auto() is deprecated" , call. = FALSE )
329
+ warn (" aes_auto() is deprecated" )
331
330
332
331
# detect names of data
333
332
if (is.null(data )) {
334
- stop (" aes_auto requires data.frame or names of data.frame." )
333
+ abort (" aes_auto requires data.frame or names of data.frame." )
335
334
} else if (is.data.frame(data )) {
336
335
vars <- names(data )
337
336
} else {
@@ -380,11 +379,7 @@ warn_for_aes_extract_usage_expr <- function(x, data, env = emptyenv()) {
380
379
if (is_call(x , " [[" ) || is_call(x , " $" )) {
381
380
if (extract_target_is_likely_data(x , data , env )) {
382
381
good_usage <- alternative_aes_extract_usage(x )
383
- warning(
384
- " Use of `" , format(x ), " ` is discouraged. " ,
385
- " Use `" , good_usage , " ` instead." ,
386
- call. = FALSE
387
- )
382
+ warn(glue(" Use of `{format(x)}` is discouraged. Use `{good_usage}` instead." ))
388
383
}
389
384
} else if (is.call(x )) {
390
385
lapply(x , warn_for_aes_extract_usage_expr , data , env )
@@ -398,7 +393,7 @@ alternative_aes_extract_usage <- function(x) {
398
393
} else if (is_call(x , " $" )) {
399
394
as.character(x [[3 ]])
400
395
} else {
401
- stop( " Don't know how to get alternative usage for `" , format(x ), " ` " , call. = FALSE )
396
+ abort(glue( " Don't know how to get alternative usage for `{ format(x)}` " ) )
402
397
}
403
398
}
404
399
0 commit comments