Hi everyone,
It's been three days that I have been searching for something and I don't find any answer. I hope I will be clear with my problem.
My datasets is like on the image :
I measured the weight ("biomasse") of my plants, that is my responsive variable that I want to explain by the treatments.
I have 4 varieties, each treated with the same 4 treatments and what I want to do is to do a Tukey test to compare the different effects of the treatments on the weight of my plant for each varieties separately and then add the letters on a boxplot with facet_grid (by variety).
I did a Tukey test but what I see is that it's done on all the treatments for all the varieties in the same time, which is not what I want to explain.
The code
library(ggplot2)
library(multcompView)
library(dplyr)
library(graphics)
model3 = aov(Biomasse ~ Traitement+Variété+ Traitement*Variété, data=biomasseorgemock)
#table with factors, means and standard deviation
data_summ = group_by(biomasseorgemock, Variété, Traitement) %>%
summarise(mean=mean(Biomasse), sd=sd(Biomasse)) %>%
arrange(desc(mean))
#View(data_sum)
#tukey test
Tukey= TukeyHSD(model3)
print(Tukey)
Cld=multcompLetters4(model3, Tukey)
print(Cld)
#add letter to table
Cld= as.data.frame.list(Cld$`Traitement:Variété`)
data_summ$Cld=Cld$Letters
print(data_summ)
View(data_summ)
#write.csv(data_sum, "massracinoc_summary.csv")
qq=ggplot(biomasseorgemock, aes(x=Traitement, y=Biomasse, fill = Traitement)) +
geom_boxplot(outlier.shape = NA) +
geom_text(data = data_summ, aes(label=Cld,x=Traitement, y=mean +sd), position=position_dodge2(0.75), vjust = -6) + ylim(0,0.6) +
labs(x="Traitements", y = "Biomasses aériennes (g)") + facet_grid(.~Variété)
qq
I obtain this new dataframe with all the letters but it's not grouped by variety.
I tried to create subsets (on another script because I need to do that on 3 different datasets two answer different questions) of my datasets to select only one variety but I can't have the subset (maybe the dataframe is too short ??) it's written "0 observations of 4 variables".
It doesn't work well but at the end I would like to obtain this graph but with a, b, c letters to compare the four treatment on each variety.
I hope i'm clear enough and that I wrote correctly the post with the run and the images.
Thank you for your help and your answers