I'm trying to create a boxplot with ggplot of a count (MedMean) on yaxis and various independent samples (Site_Name) on xaxis.
ggplot(medianlist,aes(x=reorder(Site_Name,MedMean,FUN=median),y=MedMean))+
geom_boxplot()
I want to add Tukey's significance letters to the boxes.
Thanks
Using agricolae::HSD.test
you can do
library(dplyr)
library(agricolae)
library(ggplot2)
iris.summarized = iris %>% group_by(Species) %>% summarize(Max.Petal.Length=max(Petal.Length))
hsd=HSD.test(aov(Petal.Length~Species,data=iris), "Species", group=T)
ggplot(iris,aes(x=reorder(Species,Petal.Length,FUN = median),y=Petal.Length))+geom_boxplot()+geom_text(data=iris.summarized,aes(x=Species,y=0.2+Max.Petal.Length,label=hsd$groups$groups),vjust=0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With