uses_aesthetics | R Documentation |
uses_aesthetics
checks whether the student used one or more aesthetics.
uses_aesthetics(p, aesthetics, local_only = FALSE, exact = FALSE)
p |
A ggplot object or a layer extracted from a ggplot object with
|
aesthetics |
character vector of variables to check for, e.g. "x" or c("x") |
local_only |
|
exact |
If |
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.
A logical value.
require(ggplot2)
p <- ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) +
geom_point(mapping = aes(color = class))
uses_aesthetics(p, "x")
uses_aesthetics(p, c("x", "y"))
uses_aesthetics(get_geom_layer(p, "point"), c("x", "y", "color"), local_only = TRUE)
uses_aesthetics(get_geom_layer(p, "point"), c("x", "y"), local_only = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.