setwd("D://DESARROLLO DEL PROYECTO/ARTICULOS DEL PROYECTO/AVES/DIVERSIDAD/ANALISIS_AVES/ANALISIS R/DIVERSIDAD_AMBIENTALES") Polylepis <- read.csv("Datos_Completos.csv",";",header = T) Polylepis head(Polylepis) library(ggplot2) library(plotly) require(corrgram) require(ggplot2) require(lme4) require(cowplot) library(plotly) library(ggthemes) library(gridExtra) library(grid) library(lattice) require(stats) require(multcompView) require(dunn.test) require(FSA) require(PMCMR) require(ggplot2) ####box plot de altura de los arbolews de Polylepis junin ###Analisis de Kruskal wallis Polylepis <- read.csv("Datos_Completos.csv",";",header = T) head(Polylepis) tail(Polylepis) attach(Polylepis) names(Polylepis) tapply(Polylepis$TH, Polylepis$Locality, median,na.rm=TRUE) kruskal.test(TH~Locality, data=Polylepis) out <- posthoc.kruskal.dunn.test(TH ~ Locality,data = Polylepis, p.adjust="bonf") summary(out) out out.p <- get.pvalues(out) out.mcV <- multcompLetters(out.p, threshold=0.01) out.mcV #### Altura de los arboles de polylepis TH<- ggplot(Polylepis, aes(x=reorder(Locality,TH), y=TH, fill=interaction(Species,Locality), dodge=Species))+ stat_boxplot(geom = "errorbar", width = 0.35)+ geom_boxplot(position=position_dodge(width=0.8))+ theme_classic()+ theme(axis.text.x = element_text(face="bold",color="black", size=11, angle=0), axis.text.y = element_text(face="bold", color="black", size=9, angle=0))+ scale_fill_manual(values=c("gray60","gray30","gray30","gray30", "gray90","gray90","gray60","gray30"))+xlab("Locality") + ylab("height of trees per 10x10 m plot (m)")+scale_y_continuous(breaks = c(1,3,5,7,9,11,13,15))+ theme(axis.text=element_text(size=8),axis.title=element_text(size=12,face="bold"))+ theme(legend.position = "bottom", legend.direction = "horizontal")+ annotate("text", x = "Qui", y = 7, label = "a",parse = TRUE,size=6)+ annotate("text", x = "Cha", y = 9.5, label = "b",parse = TRUE,size=6)+ annotate("text", x = "Pau", y = 9.5, label = "b",parse = TRUE,size=6)+ annotate("text", x = "Sha", y = 12, label = "c",parse = TRUE,size=6)+ annotate("text", x = "Juc", y = 14.5, label = "d",parse = TRUE,size=6)+ annotate("text", x = "Lla", y = 14.5, label = "d",parse = TRUE,size=6)+ annotate("text", x = "Nah", y = 15.3, label = "de",parse = TRUE,size=6)+ annotate("text", x = "Tas", y = 14, label = "e",parse = TRUE,size=6)+ theme(legend.title=element_blank()) TH #+ stat_boxplot(geom ='errorbar') #### Diametro de los arboles de polylepis tapply(Polylepis$DGL, Polylepis$Locality, median,na.rm=TRUE) kruskal.test(DGL~Locality, data=Polylepis) out <- posthoc.kruskal.dunn.test(DGL ~ Locality,data = Polylepis, p.adjust="bonf") summary(out) out out.p <- get.pvalues(out) out.mcV <- multcompLetters(out.p, threshold=0.01) out.mcV DGL<-ggplot(Polylepis, aes(x=reorder(Locality,DGL),y=DGL, fill=interaction(Species,Locality), dodge=Species))+ stat_boxplot(geom = "errorbar", width = 0.35)+ geom_boxplot(position=position_dodge(width=0.8))+ theme_classic()+ theme(axis.text.x = element_text(face="bold",color="black", size=11, angle=0), axis.text.y = element_text(face="bold", color="black", size=9, angle=0))+ scale_fill_manual(values=c("gray60","gray30","gray30","gray30", "gray90","gray90","gray60","gray30"))+xlab("Locality") + ylab("dgl of trees per 10x10 m plot (m)")+scale_y_continuous(breaks = c(10,20,30,40,50,60,70))+ theme(axis.text=element_text(size=8),axis.title=element_text(size=12,face="bold"))+ theme(legend.position = "bottom", legend.direction = "horizontal")+ annotate("text", x = "Qui", y = 35, label = "a",parse = TRUE,size=6)+ annotate("text", x = "Pau", y = 35, label = "a",parse = TRUE,size=6)+ annotate("text", x = "Cha", y = 40, label = "b",parse = TRUE,size=6)+ annotate("text", x = "Sha", y = 40, label = "b",parse = TRUE,size=6)+ annotate("text", x = "Lla", y = 40, label = "b",parse = TRUE,size=6)+ annotate("text", x = "Juc", y = 40, label = "b",parse = TRUE,size=6)+ annotate("text", x = "Nah", y = 59, label = "c",parse = TRUE,size=6)+ annotate("text", x = "Tas", y = 72, label = "d",parse = TRUE,size=6)+ theme(legend.title=element_blank()) DGL Figure_3<- plot_grid(TH,DGL, labels = c("",""), align="v", axis="l",rel_widths = c(1,1), nrow = 1,ncol=2) Figure_3 ###save the figure in 800 dpi, format jpg ggsave(Figure_3,width=12, height=4, file="Figure 3.jpg", dpi = 800)