58
58
# ' `NA`, the default, includes if any aesthetics are mapped.
59
59
# ' `FALSE` never includes, and `TRUE` always includes.
60
60
# ' It can also be a named logical vector to finely select the aesthetics to
61
- # ' display. To include legend keys for all levels, even
62
- # ' when no data exists, use `TRUE`. If `NA`, all levels are shown in legend,
61
+ # ' display. To include legend keys for all levels, even
62
+ # ' when no data exists, use `TRUE`. If `NA`, all levels are shown in legend,
63
63
# ' but unobserved levels are omitted.
64
64
# ' @param inherit.aes If `FALSE`, overrides the default aesthetics,
65
65
# ' rather than combining with them. This is most useful for helper functions
@@ -303,10 +303,7 @@ Layer <- ggproto("Layer", NULL,
303
303
}
304
304
305
305
# Evaluate aesthetics
306
- env <- child_env(baseenv(), stage = stage )
307
- evaled <- lapply(aesthetics , eval_tidy , data = data , env = env )
308
- evaled <- compact(evaled )
309
-
306
+ evaled <- eval_aesthetics(aesthetics , data )
310
307
plot $ scales $ add_defaults(evaled , plot $ plot_env )
311
308
312
309
# Check for discouraged usage in mapping
@@ -386,14 +383,10 @@ Layer <- ggproto("Layer", NULL,
386
383
data_orig <- plot $ scales $ backtransform_df(data )
387
384
388
385
# Add map stat output to aesthetics
389
- env <- child_env(baseenv(), stat = stat , after_stat = after_stat )
390
- stage_mask <- child_env(emptyenv(), stage = stage_calculated )
391
- mask <- new_data_mask(as_environment(data_orig , stage_mask ), stage_mask )
392
- mask $ .data <- as_data_pronoun(mask )
393
-
394
- new <- substitute_aes(new )
395
- stat_data <- lapply(new , eval_tidy , mask , env )
396
-
386
+ stat_data <- eval_aesthetics(
387
+ substitute_aes(new ), data_orig ,
388
+ mask = list (stage = stage_calculated )
389
+ )
397
390
# Check that all columns in aesthetic stats are valid data
398
391
nondata_stat_cols <- check_nondata_cols(stat_data )
399
392
if (length(nondata_stat_cols ) > 0 ) {
@@ -407,8 +400,7 @@ Layer <- ggproto("Layer", NULL,
407
400
))
408
401
}
409
402
410
- names(stat_data ) <- names(new )
411
- stat_data <- data_frame0(!!! compact(stat_data ))
403
+ stat_data <- data_frame0(!!! stat_data )
412
404
413
405
# Add any new scales, if needed
414
406
plot $ scales $ add_defaults(stat_data , plot $ plot_env )
0 commit comments