Learn R Programming

JWileymisc (version 1.4.1)

TukeyHSDgg: Tukey HSD Plot

Description

This calculates and displays means, confidence intervals as well as which groups are different based on Tukey's HSD. Inspired by http://stackoverflow.com/questions/18771516/is-there-a-function-to-add-aov-post-hoc-testing-results-to-ggplot2-boxplot

Usage

TukeyHSDgg(x, y, d, ci = 0.95, idvar, ...)

Value

A ggplot graph object.

Arguments

x

A categorical grouping variable name.

y

A continuous outcome variable name.

d

A dataset

ci

A numeric value indicating the coverage of the confidence interval to use. Defaults to 0.95.

idvar

An optional ID variable for multilevel data

...

Additional arguments passed on.

Examples

Run this code

## examples using it with single level data
## differences based on an ANOVA and follow up contrasts
mtcars$cyl <- factor(mtcars$cyl)
TukeyHSDgg("cyl", "mpg", mtcars)
rm(mtcars)

if (FALSE) {
TukeyHSDgg("Species", "Sepal.Length", iris)

## example based on multilevel data
## differences based on model fit with lmer and follow up contrasts
TukeyHSDgg("treatment", "decrease", OrchardSprays, idvar = "colpos")
}

Run the code above in your browser using DataLab