################0. DATOS###
rm(list = ls(all.names = TRUE))
rom <- read.csv("C:/roman/TRABAJO DE INVESTIGACION.csv") 
X.ESP<-rom[c(1,2,3,4,5)]#Seleccion de columnas de interes
head(X.ESP)
##   ESPECIE MEDICION ALTURA DIAMETRO  X
## 1       1        1   16.0      3.0 NA
## 2       1        2   17.0      3.0 NA
## 3       1        3   17.5      3.0 NA
## 4       1        4   18.0      3.0 NA
## 5       1        5   18.0      3.5 NA
## 6       1        6   18.0      3.5 NA
#########################1. ANALISIS DE TODOS LOS  DATOS JUNTOS################
##########1.1 ANALISIS DESCRIPTIVO ##################
descr <- with(X.ESP, data.frame(
                       ESPECIE = sort (unique(ESPECIE)),
                       M.ALT= tapply(ALTURA, ESPECIE, mean, na.rm = T),
                       M.DIAM= tapply(DIAMETRO, ESPECIE, mean, na.rm = T),
                       
                       SD.ALT= tapply(ALTURA, ESPECIE, sd, na.rm = T),
                       SD.DIAM= tapply(DIAMETRO, ESPECIE, sd, na.rm = T),
                       
                       MEDIAN.ALT= tapply(ALTURA, ESPECIE, median, na.rm = T),
                       MEDIAN.DIAM= tapply(DIAMETRO, ESPECIE,median, na.rm = T),
                       
                       RANGE.ALT= tapply(ALTURA, ESPECIE, range, na.rm = T),
                       RANGE.DIAM= tapply(DIAMETRO, ESPECIE, range, na.rm = T)
                       )
                  )
head(descr,9)
##   ESPECIE    M.ALT   M.DIAM   SD.ALT   SD.DIAM MEDIAN.ALT MEDIAN.DIAM
## 1       1 16.39333 3.186667 3.854410 0.8875706      16.25         3.0
## 2       2 19.36000 2.940667 5.813035 0.5470623      19.00         3.0
## 3       3 21.72333 2.476667 4.690251 0.4379057      22.00         2.5
## 4       4 24.17833 3.156667 4.812438 0.5801530      25.00         3.0
## 5       5 32.44000 2.985000 5.087009 0.5129836      32.50         3.0
##    RANGE.ALT RANGE.DIAM
## 1  8.0, 24.5       1, 6
## 2      9, 37   2.0, 4.5
## 3  7.0, 34.5   1.5, 3.0
## 4 11.0, 34.5       2, 5
## 5 16.0, 46.5   1.0, 4.5
#############################1.2 ANOVA DE LA ALTURA##################################
library(agricolae)
str(X.ESP)
## 'data.frame':    1500 obs. of  5 variables:
##  $ ESPECIE : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ MEDICION: int  1 2 3 4 5 6 1 2 3 4 ...
##  $ ALTURA  : num  16 17 17.5 18 18 18 13 12.5 12.5 12.5 ...
##  $ DIAMETRO: num  3 3 3 3 3.5 3.5 4 4 4 4 ...
##  $ X       : logi  NA NA NA NA NA NA ...
X.ESP$MEDICION= factor(X.ESP$MEDICION)
X.ESP$ESPECIE= factor(X.ESP$ESPECIE)
modelo<-aov(ALTURA~MEDICION+ESPECIE,data=X.ESP)
summary(modelo)
##               Df Sum Sq Mean Sq F value Pr(>F)    
## MEDICION       5   4138     828   38.96 <2e-16 ***
## ESPECIE        4  44660   11165  525.66 <2e-16 ***
## Residuals   1490  31648      21                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#TUKEY EN GENERAL POR ESPECIE
tukeySP<-HSD.test(modelo,"ESPECIE", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeySP)
## $statistics
##     Mean       CV  MSerror      HSD
##   22.819 20.19668 21.23994 1.027713
## 
## $parameters
##     Df ntr StudentizedRange alpha  test  name.t
##   1490   5         3.862386  0.05 Tukey ESPECIE
## 
## $means
##     ALTURA      std   r Min  Max
## 1 16.39333 3.854410 300   8 24.5
## 2 19.36000 5.813035 300   9 37.0
## 3 21.72333 4.690251 300   7 34.5
## 4 24.17833 4.812438 300  11 34.5
## 5 32.44000 5.087009 300  16 46.5
## 
## $comparison
## NULL
## 
## $groups
##   trt    means M
## 1   5 32.44000 a
## 2   4 24.17833 b
## 3   3 21.72333 c
## 4   2 19.36000 d
## 5   1 16.39333 e
bar.err(tukeySP$means,variation="SD",horiz=FALSE,ylim=c(0,40),bar=FALSE,col="green",space=0.5, xlab="Especies",ylab="Altura (cm)",main="Media del crecimiento",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

bar.group(tukeySP$groups,horiz=FALSE,ylim=c(0,40),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#TUKEY EN GENERAL POR MEDICIÓN
tukeyMED<-HSD.test(modelo,"MEDICION", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeyMED)
## $statistics
##     Mean       CV  MSerror      HSD
##   22.819 20.19668 21.23994 1.176219
## 
## $parameters
##     Df ntr StudentizedRange alpha  test   name.t
##   1490   6         4.035352  0.05 Tukey MEDICION
## 
## $means
##   ALTURA      std   r Min  Max
## 1 20.308 6.758985 250   7 43.0
## 2 21.292 7.014954 250   7 43.0
## 3 22.402 7.092433 250   7 44.0
## 4 23.556 7.241174 250   7 46.0
## 5 24.300 7.302417 250   7 46.0
## 6 25.056 7.449756 250   7 46.5
## 
## $comparison
## NULL
## 
## $groups
##   trt  means  M
## 1   6 25.056  a
## 2   5 24.300 ab
## 3   4 23.556 bc
## 4   3 22.402 cd
## 5   2 21.292 de
## 6   1 20.308  e
bar.err(tukeyMED$means,variation="SD",horiz=FALSE,ylim=c(0,40),bar=FALSE,col="green",space=0.5, xlab="Especies",ylab="Altura (cm)",main="Media del crecimiento",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

bar.group(tukeyMED$groups,horiz=FALSE,ylim=c(0,40),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#####################1.3 ANOVA DE LA DIAMETRO#########################################
library(agricolae)
str(X.ESP)
## 'data.frame':    1500 obs. of  5 variables:
##  $ ESPECIE : Factor w/ 5 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ MEDICION: Factor w/ 6 levels "1","2","3","4",..: 1 2 3 4 5 6 1 2 3 4 ...
##  $ ALTURA  : num  16 17 17.5 18 18 18 13 12.5 12.5 12.5 ...
##  $ DIAMETRO: num  3 3 3 3 3.5 3.5 4 4 4 4 ...
##  $ X       : logi  NA NA NA NA NA NA ...
X.ESP$MEDICION= factor(X.ESP$MEDICION)
X.ESP$ESPECIE= factor(X.ESP$ESPECIE)
modelo<-aov(ALTURA~MEDICION+ESPECIE,data=X.ESP)
summary(modelo)
##               Df Sum Sq Mean Sq F value Pr(>F)    
## MEDICION       5   4138     828   38.96 <2e-16 ***
## ESPECIE        4  44660   11165  525.66 <2e-16 ***
## Residuals   1490  31648      21                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#TUKEY EN GENERAL POR ESPECIE
tukeySP<-HSD.test(modelo,"ESPECIE", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeySP)
## $statistics
##     Mean       CV  MSerror      HSD
##   22.819 20.19668 21.23994 1.027713
## 
## $parameters
##     Df ntr StudentizedRange alpha  test  name.t
##   1490   5         3.862386  0.05 Tukey ESPECIE
## 
## $means
##     ALTURA      std   r Min  Max
## 1 16.39333 3.854410 300   8 24.5
## 2 19.36000 5.813035 300   9 37.0
## 3 21.72333 4.690251 300   7 34.5
## 4 24.17833 4.812438 300  11 34.5
## 5 32.44000 5.087009 300  16 46.5
## 
## $comparison
## NULL
## 
## $groups
##   trt    means M
## 1   5 32.44000 a
## 2   4 24.17833 b
## 3   3 21.72333 c
## 4   2 19.36000 d
## 5   1 16.39333 e
bar.err(tukeySP$means,variation="SD",horiz=FALSE,ylim=c(0,40),bar=FALSE,col="green",space=0.5, xlab="Especies",ylab="Altura (cm)",main="Media del crecimiento",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

bar.group(tukeySP$groups,horiz=FALSE,ylim=c(0,40),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#TUKEY EN GENERAL POR MEDICIÓN
tukeyMED<-HSD.test(modelo,"MEDICION", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeyMED)
## $statistics
##     Mean       CV  MSerror      HSD
##   22.819 20.19668 21.23994 1.176219
## 
## $parameters
##     Df ntr StudentizedRange alpha  test   name.t
##   1490   6         4.035352  0.05 Tukey MEDICION
## 
## $means
##   ALTURA      std   r Min  Max
## 1 20.308 6.758985 250   7 43.0
## 2 21.292 7.014954 250   7 43.0
## 3 22.402 7.092433 250   7 44.0
## 4 23.556 7.241174 250   7 46.0
## 5 24.300 7.302417 250   7 46.0
## 6 25.056 7.449756 250   7 46.5
## 
## $comparison
## NULL
## 
## $groups
##   trt  means  M
## 1   6 25.056  a
## 2   5 24.300 ab
## 3   4 23.556 bc
## 4   3 22.402 cd
## 5   2 21.292 de
## 6   1 20.308  e
bar.err(tukeyMED$means,variation="SD",horiz=FALSE,ylim=c(0,40),bar=FALSE,col="green",space=0.5, xlab="Especies",ylab="Altura (cm)",main="Media del crecimiento",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

bar.group(tukeyMED$groups,horiz=FALSE,ylim=c(0,40),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#########################2. ANALISIS DE LOS DATOS POR MEDICIONES#####################
##########################2.1. ALTURA################################################
rm(list = ls(all.names = TRUE))
rom <- read.csv("C:/roman/TRABAJO DE INVESTIGACION.csv")
MED.H<-rom[c(13:19)]#Seleccion de columnas de interes
head(MED.H)
##   Especie HM1  HM2  HM3  HM4  HM5  HM6
## 1       1  16 17.0 17.5 18.0 18.0 18.0
## 2       1  13 12.5 12.5 12.5 12.5 12.5
## 3       1  12 14.5 15.0 15.0 15.5 15.5
## 4       1  13 13.0 13.0 13.0 13.5 13.5
## 5       1  12 13.5 14.5 16.0 16.0 17.0
## 6       1  14 14.0 14.0 16.0 16.0 16.0
str(MED.H)
## 'data.frame':    1500 obs. of  7 variables:
##  $ Especie: int  1 1 1 1 1 1 1 1 1 1 ...
##  $ HM1    : num  16 13 12 13 12 14 17 8 15 12.5 ...
##  $ HM2    : num  17 12.5 14.5 13 13.5 14 19.5 11 16 12.5 ...
##  $ HM3    : num  17.5 12.5 15 13 14.5 14 20 11 16.5 13.5 ...
##  $ HM4    : num  18 12.5 15 13 16 16 21 11 17.5 14 ...
##  $ HM5    : num  18 12.5 15.5 13.5 16 16 21 11 18.5 14 ...
##  $ HM6    : num  18 12.5 15.5 13.5 17 16 21 11 19.5 14 ...
#MEDICION 1###########
MED.H$Especie= factor(MED.H$Especie) 
modeloH1<-aov(HM1~Especie,data=MED.H)
summary(modeloH1)
##              Df Sum Sq Mean Sq F value Pr(>F)    
## Especie       4   7209    1802     106 <2e-16 ***
## Residuals   245   4166      17                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1250 observations deleted due to missingness
#TUKEY
tukeyH1<-HSD.test(modeloH1,"Especie", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeyH1)
## $statistics
##     Mean       CV MSerror      HSD
##   20.308 20.30645  17.006 2.266625
## 
## $parameters
##    Df ntr StudentizedRange alpha  test  name.t
##   245   5         3.886544  0.05 Tukey Especie
## 
## $means
##     HM1      std  r Min  Max
## 1 14.44 2.916596 50   8 19.0
## 2 16.68 4.631040 50   9 26.0
## 3 18.09 3.063428 50   7 22.5
## 4 22.77 4.769386 50  11 31.0
## 5 29.56 4.790126 50  16 43.0
## 
## $comparison
## NULL
## 
## $groups
##   trt means  M
## 1   5 29.56  a
## 2   4 22.77  b
## 3   3 18.09  c
## 4   2 16.68 cd
## 5   1 14.44  d
bar.group(tukeyH1$groups,horiz=FALSE,ylim=c(0,40),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#MEDICION 2###########
modeloH2<-aov(HM2~Especie,data=MED.H)
summary(modeloH2)
##              Df Sum Sq Mean Sq F value Pr(>F)    
## Especie       4   7564  1890.9   98.78 <2e-16 ***
## Residuals   245   4690    19.1                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1250 observations deleted due to missingness
#TUKEY
tukeyH2<-HSD.test(modeloH2,"Especie", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeyH2)
## $statistics
##     Mean       CV  MSerror      HSD
##   21.292 20.54812 19.14155 2.404734
## 
## $parameters
##    Df ntr StudentizedRange alpha  test  name.t
##   245   5         3.886544  0.05 Tukey Especie
## 
## $means
##     HM2      std  r Min  Max
## 1 15.40 3.305839 50   8 20.5
## 2 17.40 4.991830 50   9 27.5
## 3 19.48 3.532589 50   7 25.5
## 4 23.16 4.824935 50  11 31.5
## 5 31.02 4.909341 50  18 43.0
## 
## $comparison
## NULL
## 
## $groups
##   trt means  M
## 1   5 31.02  a
## 2   4 23.16  b
## 3   3 19.48  c
## 4   2 17.40 cd
## 5   1 15.40  d
bar.group(tukeyH2$groups,horiz=FALSE,ylim=c(0,40),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#MEDICION 3###########
modeloH3<-aov(HM3~Especie,data=MED.H)
summary(modeloH3)
##              Df Sum Sq Mean Sq F value Pr(>F)    
## Especie       4   7483  1870.6   90.88 <2e-16 ***
## Residuals   245   5043    20.6                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1250 observations deleted due to missingness
#TUKEY
tukeyH3<-HSD.test(modeloH3,"Especie", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeyH3)
## $statistics
##     Mean      CV  MSerror      HSD
##   22.402 20.2519 20.58284 2.493625
## 
## $parameters
##    Df ntr StudentizedRange alpha  test  name.t
##   245   5         3.886544  0.05 Tukey Especie
## 
## $means
##     HM3      std  r Min Max
## 1 16.24 3.669010 50   8  23
## 2 18.78 5.370137 50  10  30
## 3 21.09 3.776525 50   7  27
## 4 23.75 4.819444 50  12  33
## 5 32.15 4.808846 50  18  44
## 
## $comparison
## NULL
## 
## $groups
##   trt means M
## 1   5 32.15 a
## 2   4 23.75 b
## 3   3 21.09 c
## 4   2 18.78 c
## 5   1 16.24 d
bar.group(tukeyH3$groups,horiz=FALSE,ylim=c(0,40),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#MEDICION 4###########
modeloH4<-aov(HM4~Especie,data=MED.H)
summary(modeloH4)
##              Df Sum Sq Mean Sq F value Pr(>F)    
## Especie       4   7659    1915   86.91 <2e-16 ***
## Residuals   245   5398      22                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1250 observations deleted due to missingness
#TUKEY
tukeyH4<-HSD.test(modeloH4,"Especie", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeyH4)
## $statistics
##     Mean       CV  MSerror      HSD
##   23.556 19.92582 22.03106 2.579861
## 
## $parameters
##    Df ntr StudentizedRange alpha  test  name.t
##   245   5         3.886544  0.05 Tukey Especie
## 
## $means
##     HM4      std  r Min Max
## 1 17.04 3.988299 50   8  24
## 2 20.14 5.665002 50  10  32
## 3 22.61 4.119751 50   7  30
## 4 24.58 4.675555 50  13  33
## 5 33.41 4.829427 50  19  46
## 
## $comparison
## NULL
## 
## $groups
##   trt means  M
## 1   5 33.41  a
## 2   4 24.58  b
## 3   3 22.61 bc
## 4   2 20.14  c
## 5   1 17.04  d
bar.group(tukeyH4$groups,horiz=FALSE,ylim=c(0,40),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#MEDICION 5###########
modeloH5<-aov(HM5~Especie,data=MED.H)
summary(modeloH5)
##              Df Sum Sq Mean Sq F value Pr(>F)    
## Especie       4   7495  1873.9   79.39 <2e-16 ***
## Residuals   245   5783    23.6                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1250 observations deleted due to missingness
#TUKEY
tukeyH5<-HSD.test(modeloH5,"Especie", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeyH5)
## $statistics
##   Mean      CV  MSerror      HSD
##   24.3 19.9926 23.60212 2.670263
## 
## $parameters
##    Df ntr StudentizedRange alpha  test  name.t
##   245   5         3.886544  0.05 Tukey Especie
## 
## $means
##     HM5      std  r  Min  Max
## 1 17.49 4.043753 50  8.0 24.5
## 2 21.09 6.002287 50 11.0 35.5
## 3 23.95 4.497448 50  7.0 32.0
## 4 25.05 4.705891 50 13.5 33.5
## 5 33.92 4.822735 50 19.0 46.0
## 
## $comparison
## NULL
## 
## $groups
##   trt means M
## 1   5 33.92 a
## 2   4 25.05 b
## 3   3 23.95 b
## 4   2 21.09 c
## 5   1 17.49 d
bar.group(tukeyH5$groups,horiz=FALSE,ylim=c(0,40),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#MEDICION 6###########
modeloH6<-aov(HM6~Especie,data=MED.H)
summary(modeloH6)
##              Df Sum Sq Mean Sq F value Pr(>F)    
## Especie       4   7675  1918.8   76.51 <2e-16 ***
## Residuals   245   6144    25.1                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1250 observations deleted due to missingness
#TUKEY
tukeyH6<-HSD.test(modeloH6,"Especie", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeyH6)
## $statistics
##     Mean       CV  MSerror      HSD
##   25.056 19.98657 25.07841 2.752508
## 
## $parameters
##    Df ntr StudentizedRange alpha  test  name.t
##   245   5         3.886544  0.05 Tukey Especie
## 
## $means
##     HM6      std  r  Min  Max
## 1 17.75 4.128361 50  8.0 24.5
## 2 22.07 6.333431 50 12.5 37.0
## 3 25.12 4.925527 50  7.0 34.5
## 4 25.76 4.615015 50 14.0 34.5
## 5 34.58 4.762052 50 20.0 46.5
## 
## $comparison
## NULL
## 
## $groups
##   trt means M
## 1   5 34.58 a
## 2   4 25.76 b
## 3   3 25.12 b
## 4   2 22.07 c
## 5   1 17.75 d
bar.group(tukeyH6$groups,horiz=FALSE,ylim=c(0,40),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

############################2.2 DIAMETRO###############################################
rm(list = ls(all.names = TRUE))
rom <- read.csv("C:/roman/TRABAJO DE INVESTIGACION.csv")
MED.D<-rom[c(13,20:25)]#Seleccion de columnas de interes
head(MED.D)
##   Especie DM1 DM2 DM3 DM4 DM5 DM6
## 1       1   3 3.0 3.0 3.0 3.5 3.5
## 2       1   4 4.0 4.0 4.0 4.0 4.5
## 3       1   2 2.0 2.0 2.0 3.0 3.0
## 4       1   3 3.0 3.0 3.0 4.0 4.0
## 5       1   3 3.5 3.5 3.5 3.5 3.5
## 6       1   4 4.0 4.0 4.0 4.0 4.0
str(MED.D)
## 'data.frame':    1500 obs. of  7 variables:
##  $ Especie: int  1 1 1 1 1 1 1 1 1 1 ...
##  $ DM1    : num  3 4 2 3 3 4 3 5 3 2 ...
##  $ DM2    : num  3 4 2 3 3.5 4 3 5 3 2 ...
##  $ DM3    : num  3 4 2 3 3.5 4 3 5 3 2 ...
##  $ DM4    : num  3 4 2 3 3.5 4 3 6 3 2 ...
##  $ DM5    : num  3.5 4 3 4 3.5 4 3 5 3 2 ...
##  $ DM6    : num  3.5 4.5 3 4 3.5 4 3 5 3 2 ...
MED.D$Especie= factor(MED.D$Especie) 

#MEDICION 1###########
modeloD1<-aov(DM1~Especie,data=MED.D)
summary(modeloD1)
##              Df Sum Sq Mean Sq F value   Pr(>F)    
## Especie       4  15.91   3.977   11.17 2.42e-08 ***
## Residuals   245  87.19   0.356                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1250 observations deleted due to missingness
#TUKEY
tukeyD1<-HSD.test(modeloD1,"Especie", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeyD1)
## $statistics
##    Mean       CV   MSerror       HSD
##   2.796 21.33601 0.3558776 0.3278905
## 
## $parameters
##    Df ntr StudentizedRange alpha  test  name.t
##   245   5         3.886544  0.05 Tukey Especie
## 
## $means
##    DM1       std  r Min Max
## 1 3.02 0.8388525 50 1.0   5
## 2 2.75 0.5824824 50 2.0   4
## 3 2.33 0.4357728 50 1.5   3
## 4 3.00 0.5050763 50 2.0   4
## 5 2.88 0.5398412 50 1.0   4
## 
## $comparison
## NULL
## 
## $groups
##   trt means M
## 1   1  3.02 a
## 2   4  3.00 a
## 3   5  2.88 a
## 4   2  2.75 a
## 5   3  2.33 b
bar.group(tukeyD1$groups,horiz=FALSE,ylim=c(0,4),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#MEDICION 2###########
modeloD2<-aov(DM2~Especie,data=MED.D)
summary(modeloD2)
##              Df Sum Sq Mean Sq F value   Pr(>F)    
## Especie       4  15.87   3.968   11.62 1.17e-08 ***
## Residuals   245  83.65   0.341                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1250 observations deleted due to missingness
#TUKEY
tukeyD2<-HSD.test(modeloD2,"Especie", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeyD2)
## $statistics
##     Mean      CV  MSerror      HSD
##   2.8448 20.5393 0.341409 0.321156
## 
## $parameters
##    Df ntr StudentizedRange alpha  test  name.t
##   245   5         3.886544  0.05 Tukey Especie
## 
## $means
##     DM2       std  r Min Max
## 1 3.050 0.8586297 50 1.0   5
## 2 2.864 0.5461404 50 2.0   4
## 3 2.360 0.4290474 50 1.5   3
## 4 3.030 0.5092011 50 2.0   4
## 5 2.920 0.4776644 50 1.5   4
## 
## $comparison
## NULL
## 
## $groups
##   trt means M
## 1   1 3.050 a
## 2   4 3.030 a
## 3   5 2.920 a
## 4   2 2.864 a
## 5   3 2.360 b
bar.group(tukeyD2$groups,horiz=FALSE,ylim=c(0,4),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#MEDICION 3###########
modeloD3<-aov(DM3~Especie,data=MED.D)
summary(modeloD3)
##              Df Sum Sq Mean Sq F value   Pr(>F)    
## Especie       4  15.69   3.921   11.23 2.21e-08 ***
## Residuals   245  85.55   0.349                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1250 observations deleted due to missingness
#TUKEY
tukeyD3<-HSD.test(modeloD3,"Especie", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeyD3)
## $statistics
##    Mean       CV   MSerror       HSD
##   2.916 20.26467 0.3491837 0.3247921
## 
## $parameters
##    Df ntr StudentizedRange alpha  test  name.t
##   245   5         3.886544  0.05 Tukey Especie
## 
## $means
##    DM3       std  r Min Max
## 1 3.14 0.9037338 50 1.0 5.0
## 2 2.93 0.4949747 50 2.0 4.0
## 3 2.44 0.4120630 50 1.5 3.0
## 4 3.10 0.5345225 50 2.0 4.5
## 5 2.97 0.4781981 50 1.5 4.0
## 
## $comparison
## NULL
## 
## $groups
##   trt means M
## 1   1  3.14 a
## 2   4  3.10 a
## 3   5  2.97 a
## 4   2  2.93 a
## 5   3  2.44 b
bar.group(tukeyD3$groups,horiz=FALSE,ylim=c(0,4),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#MEDICION 4###########
modeloD4<-aov(DM4~Especie,data=MED.D)
summary(modeloD4)
##              Df Sum Sq Mean Sq F value   Pr(>F)    
## Especie       4  15.27   3.818   9.705 2.66e-07 ***
## Residuals   245  96.39   0.393                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1250 observations deleted due to missingness
#TUKEY
tukeyD4<-HSD.test(modeloD4,"Especie", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeyD4)
## $statistics
##    Mean       CV  MSerror       HSD
##   2.982 21.03471 0.393449 0.3447647
## 
## $parameters
##    Df ntr StudentizedRange alpha  test  name.t
##   245   5         3.886544  0.05 Tukey Especie
## 
## $means
##    DM4       std  r Min Max
## 1 3.21 0.9587939 50 1.0   6
## 2 2.99 0.5100020 50 2.0   4
## 3 2.52 0.4280950 50 1.5   3
## 4 3.18 0.5869325 50 2.0   5
## 5 3.01 0.5100020 50 1.5   4
## 
## $comparison
## NULL
## 
## $groups
##   trt means M
## 1   1  3.21 a
## 2   4  3.18 a
## 3   5  3.01 a
## 4   2  2.99 a
## 5   3  2.52 b
bar.group(tukeyD4$groups,horiz=FALSE,ylim=c(0,4),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#MEDICION 5###########
modeloD5<-aov(DM5~Especie,data=MED.D)
summary(modeloD5)
##              Df Sum Sq Mean Sq F value   Pr(>F)    
## Especie       4  17.92   4.479   11.86 8.03e-09 ***
## Residuals   245  92.54   0.378                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1250 observations deleted due to missingness
#TUKEY
tukeyD5<-HSD.test(modeloD5,"Especie", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeyD5)
## $statistics
##    Mean       CV   MSerror       HSD
##   3.034 20.25713 0.3777347 0.3378096
## 
## $parameters
##    Df ntr StudentizedRange alpha  test  name.t
##   245   5         3.886544  0.05 Tukey Especie
## 
## $means
##    DM5       std  r Min Max
## 1 3.32 0.8792390 50 1.5   5
## 2 3.01 0.5296321 50 2.0   4
## 3 2.56 0.4361239 50 1.5   3
## 4 3.26 0.6081085 50 2.0   5
## 5 3.02 0.5245017 50 1.5   4
## 
## $comparison
## NULL
## 
## $groups
##   trt means M
## 1   1  3.32 a
## 2   4  3.26 a
## 3   5  3.02 a
## 4   2  3.01 a
## 5   3  2.56 b
bar.group(tukeyD5$groups,horiz=FALSE,ylim=c(0,4),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#MEDICION 6###########
modeloD6<-aov(DM6~Especie,data=MED.D)
summary(modeloD6)
##              Df Sum Sq Mean Sq F value   Pr(>F)    
## Especie       4  17.57   4.394    11.1 2.72e-08 ***
## Residuals   245  96.95   0.396                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1250 observations deleted due to missingness
#TUKEY
tukeyD6<-HSD.test(modeloD6,"Especie", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukeyD6)
## $statistics
##    Mean       CV   MSerror       HSD
##   3.122 20.14973 0.3957347 0.3457647
## 
## $parameters
##    Df ntr StudentizedRange alpha  test  name.t
##   245   5         3.886544  0.05 Tukey Especie
## 
## $means
##    DM6       std  r Min Max
## 1 3.38 0.8663788 50 1.5 5.0
## 2 3.10 0.5714286 50 2.0 4.5
## 3 2.65 0.4195479 50 1.5 3.0
## 4 3.37 0.6609363 50 2.0 5.0
## 5 3.11 0.5372834 50 1.5 4.5
## 
## $comparison
## NULL
## 
## $groups
##   trt means M
## 1   1  3.38 a
## 2   4  3.37 a
## 3   5  3.11 a
## 4   2  3.10 a
## 5   3  2.65 b
bar.group(tukeyD6$groups,horiz=FALSE,ylim=c(0,4),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#################################3. ANALISIS DE MEDIDAS REPETIDAS##########################
MED.H<- read.csv("C:/roman/BIOM.csv")
head(MED.H,6)
##   Especie HM1  HM2  HM3  HM4  HM5  HM6 DM1 DM2 DM3 DM4 DM5 DM6
## 1       1  16 17.0 17.5 18.0 18.0 18.0   3 3.0 3.0 3.0 3.5 3.5
## 2       1  13 12.5 12.5 12.5 12.5 12.5   4 4.0 4.0 4.0 4.0 4.5
## 3       1  12 14.5 15.0 15.0 15.5 15.5   2 2.0 2.0 2.0 3.0 3.0
## 4       1  13 13.0 13.0 13.0 13.5 13.5   3 3.0 3.0 3.0 4.0 4.0
## 5       1  12 13.5 14.5 16.0 16.0 17.0   3 3.5 3.5 3.5 3.5 3.5
## 6       1  14 14.0 14.0 16.0 16.0 16.0   4 4.0 4.0 4.0 4.0 4.0
library(lattice)
library(agricolae)

arrangeData <- function(data, month){
  df <- data[ , c("Especie", paste0("HM", month), paste0("DM", month))]
  df$month <- as.numeric(ifelse(as.numeric(month) >250, paste0("1", month), paste0("0", month)))
  names(df)[names(df) == paste0("HM", month)] <- "tht"
  names(df)[names(df) == paste0("DM", month)] <- "diam"
  return(df)
}# El 250 indica hasta que numero de filas empiza con otro valor, el primer paste0 indica el segundo valor, y el segundo el primer valor de la numeración.

MED.H2<- lapply(X=c("1", "2", "3","4","5","6"), FUN=function(x) arrangeData(data=MED.H, month=x))
MH2<-do.call(rbind, MED.H2)
str(MH2)
## 'data.frame':    1500 obs. of  4 variables:
##  $ Especie: int  1 1 1 1 1 1 1 1 1 1 ...
##  $ tht    : num  16 13 12 13 12 14 17 8 15 12.5 ...
##  $ diam   : num  3 4 2 3 3 4 3 5 3 2 ...
##  $ month  : num  1 1 1 1 1 1 1 1 1 1 ...
MH2$Especie= factor(MH2$Especie) 
MH2$month= factor(MH2$month) 
str(MH2) 
## 'data.frame':    1500 obs. of  4 variables:
##  $ Especie: Factor w/ 5 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ tht    : num  16 13 12 13 12 14 17 8 15 12.5 ...
##  $ diam   : num  3 4 2 3 3 4 3 5 3 2 ...
##  $ month  : Factor w/ 6 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
mod.H<-aov(tht~month+month:Especie, data=MH2) 
summary(mod.H) 
##                 Df Sum Sq Mean Sq F value Pr(>F)    
## month            5   4138   827.6   38.96 <2e-16 ***
## month:Especie   24  45084  1878.5   88.44 <2e-16 ***
## Residuals     1470  31223    21.2                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey.hp<-HSD.test(mod.H,"Especie",alpha=0.05)
head(tukey.hp)
## $statistics
##     Mean       CV  MSerror      HSD
##   22.819 20.19687 21.24033 1.027739
## 
## $parameters
##     Df ntr StudentizedRange alpha  test  name.t
##   1470   5         3.862451  0.05 Tukey Especie
## 
## $means
##        tht      std   r Min  Max
## 1 16.39333 3.854410 300   8 24.5
## 2 19.36000 5.813035 300   9 37.0
## 3 21.72333 4.690251 300   7 34.5
## 4 24.17833 4.812438 300  11 34.5
## 5 32.44000 5.087009 300  16 46.5
## 
## $comparison
## NULL
## 
## $groups
##   trt    means M
## 1   5 32.44000 a
## 2   4 24.17833 b
## 3   3 21.72333 c
## 4   2 19.36000 d
## 5   1 16.39333 e
#PROMEDIOS
alt<-tapply(MH2$tht,list(MH2$Especie,MH2$month),mean)#PROMEDIO EN ALTURA DE LAS 5 ESPECIES POR MEDICION
alt2<-t(alt)#transponer datos
medicion=c("1","2","3","4","5","6")
alt3 = data.frame(alt2, medicion)
colnames(alt3)= c("sp1","sp2","sp3","sp4","sp5","Medicion")
alt3
##     sp1   sp2   sp3   sp4   sp5 Medicion
## 1 14.44 16.68 18.09 22.77 29.56        1
## 2 15.40 17.40 19.48 23.16 31.02        2
## 3 16.24 18.78 21.09 23.75 32.15        3
## 4 17.04 20.14 22.61 24.58 33.41        4
## 5 17.49 21.09 23.95 25.05 33.92        5
## 6 17.75 22.07 25.12 25.76 34.58        6
#grafica
library(agricolae)
plot(spline(alt3$Medicion, alt3$sp1),xlab="Mes", ylab="Altura (m)",ylim=c(13,35), col="white",type="l",las=1,cex.axis=1.5,cex.lab=1.5,cex.main=1.5,font.main=1.5,font.axis=1.5,lwd=2, pch="1",lty=3, main="A) Curvas de crecimiento de Altura")
     
legend(1,1,c("sp1","sp2","sp3","sp4","sp5"),pch=c(8,22,16,18,21),col="black",cex=0.9,lty=c("twodash","solid","dotdash","solid","dotted","dashed"), lwd=2)
lines(spline(alt3$Medicion, alt3$sp1), col="black",type="o",lwd=2,pch=8,lty="twodash")
lines(spline(alt3$Medicion, alt3$sp2), col="black",type="o",lwd=2,pch=22,lty="solid")
lines(spline(alt3$Medicion, alt3$sp3), col="black",type="o",lwd=2,pch=16,lty="dotdash")
lines(spline(alt3$Medicion, alt3$sp4), col="black",type="o",lwd=2,pch=18,lty="solid")
lines(spline(alt3$Medicion, alt3$sp5), col="black",type="o",lwd=2,pch=21, lty="dotted")

diam<-tapply(MH2$diam,list(MH2$Especie,MH2$month),mean)#PROMEDIO EN DIAMETRO DE LAS 5 ESPECIES POR MEDICION
diam2<-t(diam)#transponer datos
medicion=c("1","2","3","4","5","6")
diam3 = data.frame(diam2, medicion)
colnames(diam3)= c("sp1","sp2","sp3","sp4","sp5","Medicion")
diam3
##    sp1   sp2  sp3  sp4  sp5 Medicion
## 1 3.02 2.750 2.33 3.00 2.88        1
## 2 3.05 2.864 2.36 3.03 2.92        2
## 3 3.14 2.930 2.44 3.10 2.97        3
## 4 3.21 2.990 2.52 3.18 3.01        4
## 5 3.32 3.010 2.56 3.26 3.02        5
## 6 3.38 3.100 2.65 3.37 3.11        6
plot(spline(diam3$Medicion, diam3$sp1),xlab="Mes", ylab="Altura (m)",ylim=c(2,4),xlim=c(0,6), col="white",type="l",las=1,cex.axis=1.5,cex.lab=1.5,cex.main=1.5,font.main=1.5,font.axis=1.5,lwd=2, pch="1",lty=3, main="A) Curvas de crecimiento de Altura")
     
legend(1,3.5,c("sp1","sp2","sp3","sp4","sp5"),pch=c(8,22,16,18,21),col="black",cex=0.9,lty=c("twodash","solid","dotdash","solid","dotted","dashed"), lwd=1)
lines(spline(diam3$Medicion, diam3$sp1), col="black",type="o",lwd=2,pch=8,lty="twodash")
lines(spline(diam3$Medicion, diam3$sp2), col="black",type="o",lwd=2,pch=22,lty="solid")
lines(spline(diam3$Medicion, diam3$sp3), col="black",type="o",lwd=2,pch=16,lty="dotdash")
lines(spline(diam3$Medicion, diam3$sp4), col="black",type="o",lwd=2,pch=18,lty="solid")
lines(spline(diam3$Medicion, diam3$sp5), col="black",type="o",lwd=2,pch=21, lty="dotted")#

#####################4. ANALISIS DE BIOMASA#########################################
BIOM<-rom[c(6:11)]#Seleccion de columnas de interes
head(BIOM,6)
##   ESP  PHBA PSBA PHBR PSBR NRAICES
## 1   1  5.86 1.46 0.71 0.12      13
## 2   1 10.22 2.80 1.66 0.53      26
## 3   1  9.95 2.70 1.33 0.33      41
## 4   1  6.69 1.83 1.09 0.34      27
## 5   1  9.24 2.53 1.71 0.28      42
## 6   1  9.15 2.28 1.20 0.36      48
##########4.1 ANALISIS DESCRIPTIVO#######################################
DescrBiom <- with(BIOM, data.frame(
                       ESP = sort (unique(ESP)),
                       MEAN.PHBA= tapply(PHBA, ESP, mean, na.rm = T),
                       MEAN.PSBA= tapply(PSBA, ESP, mean, na.rm = T),
                       MEAN.RAICES= tapply(NRAICES, ESP, mean, na.rm = T),
                       
                       SD.PHBR= tapply(PHBR, ESP, sd, na.rm = T),
                       SD.PSBR= tapply(PSBR, ESP, sd, na.rm = T),
                       SD.RAICES= tapply(NRAICES, ESP, sd, na.rm = T),
        
                       MEDIAN.PHBR= tapply(PHBR, ESP,median, na.rm = T),
                       MEDIAN.PSBR= tapply(PSBR, ESP,median, na.rm = T),
                       MEDIAN.RAICES= tapply(NRAICES, ESP,median, na.rm = T),
                       
                       RANGE.PHBR= tapply(PHBR, ESP, range, na.rm = T),
                       RANGE.PSBR= tapply(PSBR, ESP, range, na.rm = T),
                       RANGE.RAICES= tapply(NRAICES, ESP, range, na.rm = T)
                       )
                  )
head(DescrBiom ,9)
##   ESP MEAN.PHBA MEAN.PSBA MEAN.RAICES   SD.PHBR    SD.PSBR SD.RAICES
## 1   1     7.881     2.108        37.1 0.3539382 0.10834103 13.609229
## 2   2     6.618     1.770        23.5 0.4309795 0.12866839  7.090682
## 3   3     4.600     1.049        27.9 0.2946278 0.09975526 10.492855
## 4   4     8.343     2.296        41.3 0.4424440 0.07837942  9.499123
## 5   5     6.294     1.637        33.1 0.4568442 0.04966555  9.982763
##   MEDIAN.PHBR MEDIAN.PSBR MEDIAN.RAICES RANGE.PHBR RANGE.PSBR RANGE.RAICES
## 1       1.145       0.315          37.0 0.67, 1.71 0.12, 0.53       13, 57
## 2       2.565       0.415          23.5 1.82, 3.37 0.27, 0.62       10, 35
## 3       0.650       0.195          27.0 0.28, 1.34 0.07, 0.42       13, 41
## 4       2.185       0.465          38.0 1.26, 2.69 0.33, 0.58       29, 62
## 5       1.640       0.130          30.0 0.87, 2.29 0.06, 0.22       20, 52
#################4.2 ANOVA##########################################
library(agricolae)
str(BIOM)
## 'data.frame':    1500 obs. of  6 variables:
##  $ ESP    : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ PHBA   : num  5.86 10.22 9.95 6.69 9.24 ...
##  $ PSBA   : num  1.46 2.8 2.7 1.83 2.53 2.28 1.74 1.99 1.95 1.8 ...
##  $ PHBR   : num  0.71 1.66 1.33 1.09 1.71 1.2 1.26 0.9 1.02 0.67 ...
##  $ PSBR   : num  0.12 0.53 0.33 0.34 0.28 0.36 0.27 0.29 0.44 0.3 ...
##  $ NRAICES: int  13 26 41 27 42 48 53 57 33 31 ...
BIOM$ESP= factor(BIOM$ESP)

######################4.2.2 EN PHBA#################################################
modelo.PHBA<-aov(PHBA~ESP,data=BIOM)
summary(modelo.PHBA)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## ESP          4  86.65  21.662   10.28 5.34e-06 ***
## Residuals   45  94.83   2.107                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1450 observations deleted due to missingness
tukey.PHBA<-HSD.test(modelo.PHBA,"ESP", alpha=0.05)# Modelo de Tukey 
head(tukey.PHBA)
## $statistics
##     Mean       CV  MSerror      HSD
##   6.7472 21.51562 2.107438 1.844728
## 
## $parameters
##   Df ntr StudentizedRange alpha  test name.t
##   45   5         4.018417  0.05 Tukey    ESP
## 
## $means
##    PHBA      std  r  Min   Max
## 1 7.881 1.597105 10 5.86 10.22
## 2 6.618 1.078011 10 5.67  9.34
## 3 4.600 1.506077 10 2.61  8.27
## 4 8.343 1.821007 10 5.95 12.14
## 5 6.294 1.113555 10 4.39  7.94
## 
## $comparison
## NULL
## 
## $groups
##   trt means  M
## 1   4 8.343  a
## 2   1 7.881 ab
## 3   2 6.618 ab
## 4   5 6.294 bc
## 5   3 4.600  c
bar.err(tukey.PHBA$means,variation="SD",horiz=FALSE,ylim=c(0,12),bar=FALSE,col="green",space=0.5, xlab="Especies",ylab="Altura (cm)",main="Media del crecimiento",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

bar.err(tukey.PHBA$means,variation="range",ylim=c(0,15),bar=FALSE,col="gray", space=1,main="Rangos de Crecimientos",ylab="Ãltura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2,font.axis=2)

bar.group(tukey.PHBA$groups,horiz=FALSE,ylim=c(0,10),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#####################4.2.3 EN PSBA######################################################
modelo.PSBA<-aov(PSBA~ESP,data=BIOM)
summary(modelo.PSBA)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## ESP          4  9.284  2.3211   10.53 4.15e-06 ***
## Residuals   45  9.915  0.2203                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1450 observations deleted due to missingness
tukey.PSBA<-HSD.test(modelo.PSBA,"ESP", alpha=0.05)# Modelo de Tukey 
head(tukey.PSBA)
## $statistics
##    Mean       CV MSerror      HSD
##   1.772 26.49006 0.22034 0.596488
## 
## $parameters
##   Df ntr StudentizedRange alpha  test name.t
##   45   5         4.018417  0.05 Tukey    ESP
## 
## $means
##    PSBA       std  r  Min  Max
## 1 2.108 0.4476308 10 1.46 2.80
## 2 1.770 0.3703152 10 1.46 2.59
## 3 1.049 0.5016074 10 0.10 1.97
## 4 2.296 0.6004295 10 1.63 3.57
## 5 1.637 0.3899587 10 1.01 2.22
## 
## $comparison
## NULL
## 
## $groups
##   trt means  M
## 1   4 2.296  a
## 2   1 2.108 ab
## 3   2 1.770 ab
## 4   5 1.637 bc
## 5   3 1.049  c
bar.err(tukey.PSBA$means,variation="SD",horiz=FALSE,ylim=c(0,3),bar=FALSE,col="green",space=0.5, xlab="Especies",ylab="Altura (cm)",main="Media del crecimiento",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

bar.err(tukey.PSBA$means,variation="range",ylim=c(0,4),bar=FALSE,col="gray", space=1,main="Rangos de Crecimientos",ylab="Ãltura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2,font.axis=2)

bar.group(tukey.PSBA$groups,horiz=FALSE,ylim=c(0,3),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

###########################4.2.4 EN PHBR##################################################
modelo.PHBR<-aov(PHBR~ESP,data=BIOM)
summary(modelo.PHBR)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## ESP          4 21.675   5.419   33.77 5.03e-13 ***
## Residuals   45  7.221   0.160                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1450 observations deleted due to missingness
tukey.PHBR<-HSD.test(modelo.PHBR,"ESP", alpha=0.05)# Modelo de Tukey 
head(tukey.PHBR)
## $statistics
##     Mean      CV   MSerror       HSD
##   1.5884 25.2185 0.1604569 0.5090192
## 
## $parameters
##   Df ntr StudentizedRange alpha  test name.t
##   45   5         4.018417  0.05 Tukey    ESP
## 
## $means
##    PHBR       std  r  Min  Max
## 1 1.155 0.3539382 10 0.67 1.71
## 2 2.541 0.4309795 10 1.82 3.37
## 3 0.665 0.2946278 10 0.28 1.34
## 4 2.053 0.4424440 10 1.26 2.69
## 5 1.528 0.4568442 10 0.87 2.29
## 
## $comparison
## NULL
## 
## $groups
##   trt means  M
## 1   2 2.541  a
## 2   4 2.053  a
## 3   5 1.528  b
## 4   1 1.155 bc
## 5   3 0.665  c
bar.err(tukey.PHBR$means,variation="SD",horiz=FALSE,ylim=c(0,3),bar=FALSE,col="green",space=0.5, xlab="Especies",ylab="Altura (cm)",main="Media del crecimiento",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

bar.err(tukey.PHBR$means,variation="range",ylim=c(0,4),bar=FALSE,col="gray", space=1,main="Rangos de Crecimientos",ylab="Ãltura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2,font.axis=2)

bar.group(tukey.PHBR$groups,horiz=FALSE,ylim=c(0,3),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

######################4.2.5 EN PHBR####################################################
modelo.PSBR<-aov(PSBR~ESP,data=BIOM)
summary(modelo.PSBR)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## ESP          4 0.7365 0.18412   19.65 2.05e-09 ***
## Residuals   45 0.4217 0.00937                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1450 observations deleted due to missingness
tukey.PSBR<-HSD.test(modelo.PSBR,"ESP", alpha=0.05)# Modelo de Tukey 
head(tukey.PSBR)
## $statistics
##     Mean       CV     MSerror       HSD
##   0.3074 31.49101 0.009370889 0.1230114
## 
## $parameters
##   Df ntr StudentizedRange alpha  test name.t
##   45   5         4.018417  0.05 Tukey    ESP
## 
## $means
##    PSBR        std  r  Min  Max
## 1 0.326 0.10834103 10 0.12 0.53
## 2 0.420 0.12866839 10 0.27 0.62
## 3 0.212 0.09975526 10 0.07 0.42
## 4 0.449 0.07837942 10 0.33 0.58
## 5 0.130 0.04966555 10 0.06 0.22
## 
## $comparison
## NULL
## 
## $groups
##   trt means  M
## 1   4 0.449  a
## 2   2 0.420  a
## 3   1 0.326 ab
## 4   3 0.212 bc
## 5   5 0.130  c
bar.err(tukey.PSBR$means,variation="SD",horiz=FALSE,ylim=c(0,0.6),bar=FALSE,col="green",space=0.5, xlab="Especies",ylab="Altura (cm)",main="Media del crecimiento",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

bar.err(tukey.PSBR$means,variation="range",ylim=c(0,.7),bar=FALSE,col="gray", space=1,main="Rangos de Crecimientos",ylab="Ãltura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2,font.axis=2)

bar.group(tukey.PSBR$groups,horiz=FALSE,ylim=c(0,.6),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

####################4.2.6 EN NRAICES################################################
modelo.NRAICES<-aov(NRAICES~ESP,data=BIOM)
summary(modelo.NRAICES)
##             Df Sum Sq Mean Sq F value  Pr(>F)   
## ESP          4   2011   502.7   4.694 0.00298 **
## Residuals   45   4819   107.1                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 1450 observations deleted due to missingness
tukey.NRAICES<-HSD.test(modelo.NRAICES,"ESP", alpha=0.05)# Modelo de Tukey 
head(tukey.NRAICES)
## $statistics
##    Mean       CV  MSerror      HSD
##   32.58 31.76396 107.0956 13.15045
## 
## $parameters
##   Df ntr StudentizedRange alpha  test name.t
##   45   5         4.018417  0.05 Tukey    ESP
## 
## $means
##   NRAICES       std  r Min Max
## 1    37.1 13.609229 10  13  57
## 2    23.5  7.090682 10  10  35
## 3    27.9 10.492855 10  13  41
## 4    41.3  9.499123 10  29  62
## 5    33.1  9.982763 10  20  52
## 
## $comparison
## NULL
## 
## $groups
##   trt means   M
## 1   4  41.3   a
## 2   1  37.1  ab
## 3   5  33.1 abc
## 4   3  27.9  bc
## 5   2  23.5   c
bar.err(tukey.NRAICES$means,variation="SD",horiz=FALSE,ylim=c(0,60),bar=FALSE,col="green",space=0.5, xlab="Especies",ylab="Altura (cm)",main="Media del crecimiento",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

bar.err(tukey.NRAICES$means,variation="range",ylim=c(0,62),bar=FALSE,col="gray", space=1,main="Rangos de Crecimientos",ylab="Ãltura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2,font.axis=2)

bar.group(tukey.NRAICES$groups,horiz=FALSE,ylim=c(0,50),density=20,col="black",main="Grupos de Crecimientos",border="12",ylab="Altura (cm)",xlab="Especies",las=1,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)