uses_aesthetics checks whether the student used one or more aesthetics.
Arguments
- p
 A ggplot object or a layer extracted from a ggplot object with
get_geom_layerorget_stat_layer..- aesthetics
 character vector of variables to check for, e.g. "x" or c("x")
- local_only
 TRUEorFALSE. Shoulduses_aestheticsonly return mappings defined locally in the layer?- exact
 If
TRUE, variables need to be mapped exactly
Details
By default, uses_aesthetics requires that only one of the
aesthetics need to be used. Set exact to TRUE to check if all of
the variables have to be matched exactly.
Examples
require(ggplot2)
p <- ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) +
  geom_point(mapping = aes(color = class))
uses_aesthetics(p, "x")
#> [1] TRUE
uses_aesthetics(p, c("x", "y"))
#> [1] TRUE
uses_aesthetics(get_geom_layer(p, "point"), c("x", "y", "color"), local_only = TRUE)
#> [1] TRUE
uses_aesthetics(get_geom_layer(p, "point"), c("x", "y"), local_only = FALSE)
#> [1] TRUE
