| geom_tukey | R Documentation |
stat_tukey() fits a one-way aov(response ~ factor) per group and
computes Tukey's HSD pairwise differences with stats::TukeyHSD().
geom_tukey() draws them as horizontal error bars with points, plus a red
reference line at zero, and labels the y axis with the comparisons. Groups
(e.g. a colour mapping) are dodged, and facets work as usual.
geom_tukey(
mapping = NULL,
data = NULL,
...,
conf.level = 0.95,
dodge = 0.5,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
stat_tukey(
mapping = NULL,
data = NULL,
geom = "pointrange",
position = "identity",
...,
conf.level = 0.95,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
... |
Other arguments passed on to
|
conf.level |
Family-wise confidence level, passed to |
dodge |
Dodging width between groups. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
geom |
The geometric object to use display the data. |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
The input variables are given through the non-positional response and
factor aesthetics, because ggplot2 maps a discrete x to integers before
the stat runs. For the same reason the comparisons are placed on a
continuous y axis: y is the comparison index, x = diff,
xmin/xmax = lwr/upr. The stat also returns comparison (the label)
and p.adj. geom_tukey() adds the matching y axis labels; with
stat_tukey() alone the y axis shows the indices.
A ggplot2 layer (stat_tukey()) or a set of layers (geom_tukey()).
ggTukey()
library(ggplot2)
ggplot(battery, aes(response = Response, factor = Material, colour = Temperature)) +
geom_tukey(conf.level = 0.99) +
labs(x = "Difference", y = "Material")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.