uses_stats | R Documentation |
uses_stats
tests whether a plot uses one or more stats in its layers.
uses_stats(p, stats, geoms = NULL, exact = TRUE)
p |
A ggplot object |
stats |
A vector of character strings. Each element should correspond to
the suffix of a ggplot2 |
geoms |
A character vector to optionally check for the geoms corresponding to stats e.g. c("point", "smooth") if checking c("identity", "smooth") |
exact |
if |
By default, the plot must have the exact stats or geom/stat combinations and in the same order.
However, if exact
is set to FALSE
, the plot stats or geom/stat combinations do not have to be exact.
TRUE
or FALSE
Other functions for checking stats:
get_stats()
,
ith_stat_is()
,
ith_stat()
require(ggplot2)
p <- ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) +
geom_point(mapping = aes(color = class)) +
geom_smooth()
uses_stats(p, stats = "smooth")
uses_stats(p, stats = c("identity", "smooth"), exact = TRUE)
uses_stats(p, c("smooth", "identity"), geoms = c("smooth", "point"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.