I conducted a one way anova followed by a tukey-test in Rstudio and used a compact letter display to add letters of significance to a ggplot.
After a positive Grubbs-outlier-test I removed an outlier from the dataframe and ran the tests again. I saw that the Treatments LFs and LK still share the Tukey-letter "b" although their plots don´t overlap anymore.
Is this a possible outcome or did I make a mistake in the process?
#prepare Dataset
SampleName <- c("LK", "LK", "LK", "LK", "LK",
"LFf", "LFf", "LFf", "LFf", "LFf",
"LFa", "LFa", "LFa", "LFa", "LFa",
"LFs", "LFs", "LFs", "LFs",
"LZ", "LZ", "LZ", "LZ", "LZ")
CO2Differences_outlier <- c(LK1_diff, LK2_diff, LK3_diff,
LK4_diff, LK5_diff, LFf1_diff, LFf2_diff, LFf3_diff,
LFf4_diff, LFf5_diff, LFa1_diff, LFa2_diff, LFa3_diff,
LFa4_diff, LFa5_diff, LFs1_diff, LFs2_diff, LFs3_diff,
LFs5_diff, LZ1_diff, LZ2_diff, LZ3_diff, LZ4_diff, LZ5_diff)
CO2_outlier <- data.frame(SampleName,
CO2Differences_outlier,
stringsAsFactors = TRUE)
#run analysis and create compact letter display
anovaCO2 <- aov(CO2_outlier$CO2Differences ~
CO2_outlier$SampleName, data = CO2_outlier)
summary(anovaCO2)
tukeyCO2 <- TukeyHSD(anovaCO2)
cldCO2 <- multcompLetters4(anovaCO2, tukeyCO2)
cldCO2 <- as.data.frame.list(cldCO2$`CO2_outlier$SampleName`)
df_Letters <- data.frame(SampleName=rownames(cldCO2),
TukeyLetters = cldCO2$Letters)
#create plot
ggplot(CO2_outlier, aes(x=SampleName, y=CO2Differences_outlier)) +
geom_boxplot() +
stat_summary(fun.y=mean, geom="point", shape=9, size=2) +
geom_dotplot(binaxis='y', stackdir='center', dotsize=0.5) +
geom_text(data=df_Letters,
aes(x=SampleName ,label = TukeyLetters, y=16,
hjust=-1)) +
labs(x = "Treatment", y = "CO2 produced [mg]")