Compact letter display for lists of comparisons
cldList.RdProduces a compact letter display (cld) from pairwise comparisons that were summarized in a table of comparisons
Usage
cldList(
formula = NULL,
data = NULL,
comparison = NULL,
p.value = NULL,
threshold = 0.05,
print.comp = FALSE,
remove.space = TRUE,
remove.equal = TRUE,
remove.zero = TRUE,
swap.colon = TRUE,
swap.vs = FALSE,
...
)Arguments
- formula
A formula indicating the variable holding p-values and the variable holding the comparisons. e.g. P.adj ~ Comparison.
- data
The data frame to use.
- comparison
A vector of text describing comparisons, with each element in a form similar to "Treat.A - Treat.B = 0". Spaces and "=" and "0" are removed by default
- p.value
A vector of p-values corresponding to the comparisons in the
comparisonargument- threshold
The alpha value. That is, the p-value below which the comparison will be considered significant
- print.comp
If
TRUE, prints out a data frame of the modified text of the comparisons. Useful for debugging- remove.space
If
TRUE, removes spaces from the text of the comparisons- remove.equal
If
TRUE, removes "=" from the text of the comparisons- remove.zero
If
TRUE, removes "0" from the text of the comparisons- swap.colon
If
TRUE, swaps ":" with "-" in the text of the comparisons- swap.vs
If
TRUE, swaps "vs" with "-" in the text of the comparisons- ...
Additional arguments passed to
multcompLetters
Details
The input should include either formula and data;
or comparison and p.value.
This function relies upon the multcompLetters
function in the multcompView package. The text for the
comparisons
passed to multcompLetters should be in the form
"Treat.A-Treat.B". Currently by default cldList removes
spaces, equal signs, and zeros, by default,
and so can use
text in the form e.g.
"Treat.A - Treat.B = 0".
It also changes ":" to "-", and so can use
text in the form e.g.
"Treat.A : Treat.B".
Note
The parsing of the formula is simplistic. The first variable on the left side is used as the measurement variable. The first variable on the right side is used for the grouping variable.
It is often helpful to reorder the factor levels in the data set so that the group with the largest e.g. mean or median is first, and so on.
Author
Salvatore Mangiafico, mangiafico@njaes.rutgers.edu
Examples
data(BrendonSmall)
model = aov(Calories ~ Instructor, data=BrendonSmall)
TUK = TukeyHSD(model, "Instructor", ordered = TRUE)
### Convert the TukeyHSD output to a standard data frame
TUK = as.data.frame(TUK$Instructor)
names(TUK) = gsub(" ", ".", names(TUK))
HSD = data.frame(Comparison=row.names(TUK),
diff=TUK$diff, lwr=TUK$lwr, lwr=TUK$lwr, p.adj=TUK$p.adj)
HSD
#> Comparison diff lwr lwr.1 p.adj
#> 1 Jason Penopolis-Brendon Small 52.11111 -72.56724 -72.56724 7.548594e-01
#> 2 Melissa Robins-Brendon Small 221.55556 96.87720 96.87720 8.753993e-05
#> 3 Paula Small-Brendon Small 289.44444 164.76609 164.76609 5.990211e-07
#> 4 Coach McGuirk-Brendon Small 391.22222 266.54387 266.54387 4.084650e-10
#> 5 Melissa Robins-Jason Penopolis 169.44444 44.76609 44.76609 3.304461e-03
#> 6 Paula Small-Jason Penopolis 237.33333 112.65498 112.65498 2.777130e-05
#> 7 Coach McGuirk-Jason Penopolis 339.11111 214.43276 214.43276 1.606650e-08
#> 8 Paula Small-Melissa Robins 67.88889 -56.78946 -56.78946 5.339451e-01
#> 9 Coach McGuirk-Melissa Robins 169.66667 44.98832 44.98832 3.256342e-03
#> 10 Coach McGuirk-Paula Small 101.77778 -22.90057 -22.90057 1.562254e-01
cldList(p.adj ~ Comparison, data = HSD,
threshold = 0.05,
remove.space=FALSE)
#> Group Letter MonoLetter
#> 1 Jason Penopolis a a
#> 2 Melissa Robins b b
#> 3 Paula Small bc bc
#> 4 Coach McGuirk c c
#> 5 Brendon Small a a