问题
I'm having trouble generating a compact letter display for my results. I've run an ANOVA followed by Tukey's HSD to generate the p values for each pair, but I do not know how (or if it is possible?) to assign letters to these p values to show which pairs are significant from each other.
csa.anova<-aov(rate~temp*light,data=csa.per.chl)
summary(csa.anova)
TukeyHSD(csa.anova)
This runs the tests I need, but I don't know how to assign letters to each p value to show which pairs are significant.
回答1:
You need to install the multcomp
package first. It can compute the Tukey HSD Test and returns an object that has summary
and plot
methods. The package also has a function (cld
) to print the "compact letter display." As an example we can use the iris data set that comes with R:
library(multcomp)
data(iris)
iris.aov <- aov(Petal.Length~Species, iris)
iris.tukey <- glht(iris.aov, linfct=mcp(Species="Tukey"))
cld(iris.tukey)
# setosa versicolor virginica
# "a" "b" "c"
回答2:
I cannot make this code work:
data("iris")
iris.aov<-aov(Petal.Length~Species,iris)
iris.tukey<-glht(iris.aov,linfct=mcp(Species="Tukey"))
Here is the error triggered:
Error in glht(iris.aov, linfct = mcp(Species = "Tukey")) : could not find function "glht"
来源:https://stackoverflow.com/questions/57737598/how-to-generate-a-compact-letter-display-for-pairwise-tukeyhsd