library(groundhog) set.groundhog.folder("C:\\Groundhog_R\\R4.2.3_2023-04-01") GroundhogDay <- '2023-04-01' groundhog.library("dplyr",GroundhogDay) groundhog.library("ggplot2",GroundhogDay) groundhog.library("ggrepel",GroundhogDay) groundhog.library("lubridate",GroundhogDay) groundhog.library("tibble",GroundhogDay) groundhog.library("tidyr",GroundhogDay) groundhog.library("rstatix",GroundhogDay) groundhog.library("multcompView",GroundhogDay) setwd("D:\\Google Drive\\0_SpekboomResearchGroup2.0\\3_Experiments\\RegionalTransect21(10)_ParentPlantMaterialExperiment\\manuscript/") read.csv("data_manuscript/parentplantleafmoisturedata_2023-08-29.csv")%>% as_tibble()-> dat_leaves dat_leaves%>% mutate(Site=factor(Site,labels=paste("Site:",1:10)))-> dat_leaves # calculating the average of two replicates dat_leaves%>% group_by(Site,Individual)%>% summarise(LeafMoisture=mean(LeafMoisture))-> dat_leaves # Sites that are significantly not normally distributed dat_leaves%>% group_by(Site)%>% shapiro_test(LeafMoisture)%>% filter(p<0.06) # .:. switching to the non-parametric kruskal test dat_leaves%>% as.data.frame()%>% rstatix::kruskal_test(LeafMoisture~Site)%>% get_test_label(type = "text",detailed = TRUE) dat_leaves%>% as.data.frame()%>% kruskal_test(LeafMoisture~Site)%>% mutate(text=paste0("H=",round(statistic,1),", df=",df,", p=",p))%>% select(text) # conducting a post-hoc dunn_test. # https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/p.adjust dat_leaves%>% as.data.frame()%>% dunn_test(LeafMoisture~Site,p.adjust.method = "hochberg")-> post_hoc post_hoc$p.adj->ph_v names(ph_v) <- paste(post_hoc$group1,post_hoc$group2,sep="-") cld<- multcompLetters(ph_v)$Letters Tk<-data.frame(Site=paste0("Site: ",1:10),Letters=cld) dat_leaves%>% group_by(Site,Individual)%>% summarise(uLeafMoisture=mean(LeafMoisture))%>% ggplot(aes(as.factor(Site),uLeafMoisture))+ geom_line(colour="darkgrey",size=3)+ geom_point(colour="black",size=3)+ geom_text(data = Tk, aes(x = Site, y = 91, label = Letters),fontface = "italic")+ ylab("Leaf Moisture (%)")+ xlab("")+ theme_bw()+ geom_text_repel(aes(label=Individual)) ggsave("FinalFiguresV2/Fig_2.jpg",width=10/1.5,height=4.5/1.5)