get_stat_layer | R Documentation |
get_stat_layer
returns a stat layer from a plot along with the global data sets
and aesthetic mappings that the layer may inherit from.
get_stat_layer(p, stat = NULL, i = NULL)
p |
A ggplot object |
stat |
A character string found in the suffix of a ggplot2 stat function,
e.g. |
i |
A numerical index, e.g. |
Users can specify a layer in one of 3 ways:
By order of appearance with i
. The first layer to appear in the
plot (the one drawn first, on the bottom) corresponds to i = 1
.
By type of stat with stat
. get_stat_layer
will return the
first layer that uses the stat
By a combination of stat
and
i
. get_stat_layer
will return the ith layer that uses the stat
An object with class layer_to_check
to be manipulated further
with ggcheck functions.
require(ggplot2)
p <- ggplot(data = diamonds, aes(price)) +
stat_bin(bins = 20, binwidth = 500)
get_stat_layer(p, i = 1)
get_stat_layer(p, stat = "bin")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.