BASE DE DATOS DE PINUS oaxacana DE AMBAS LOCALIDADES DE INVESTIGACI?N.

ANOVAS POR VARIABLES

ANOVA EN ALTURA

OMZ1<-read.csv("C:/LUGO/OAXMZ.csv", header=T)
SNAMZ<- OMZ1[which(!is.na(OMZ1$H14)),] #Elim NA
tapply(SNAMZ$H14,list(SNAMZ$procedencia,SNAMZ$bloque),mean)#PROMEDIO POR BLOQUES
##          1     2     3     4     5     6     7     8     9    10    11
## IJO   8.00 12.25 10.50 10.75 11.75 11.00  9.75 10.75  9.25 11.00  8.50
## LMCO  8.00 11.50 10.75 10.50 11.00  9.50 10.25 12.00 12.00 11.50 10.75
## MZO   9.00  9.75 11.00 10.25  9.75 10.25 12.50 11.00  8.00 12.25 10.25
## RNC   7.00  9.00  9.00 10.50  9.75 12.00 11.75  7.75  9.50 10.50 10.00
## SMAO  8.00 10.50  8.50 11.25    NA 10.00 12.25  9.25 10.00 10.50    NA
## SMPO  6.50 12.00  9.50 11.00 11.00 10.25 12.00 11.00  9.75 11.25 11.50
## TPO  10.50 10.00 11.00  9.00 11.75 10.00 11.00  9.50  9.50 11.25  9.00
## XO    8.75    NA 11.00 11.75 10.75 11.00 10.50 11.50 10.00 10.25 11.00
##         12
## IJO   9.50
## LMCO 10.50
## MZO   6.50
## RNC  11.00
## SMAO  9.00
## SMPO  9.00
## TPO  10.75
## XO   10.00
#PROMEDIO POR PROCEDENCIAS
prom.proc.MZO <- with(OMZ1, data.frame(
                       procedencia = sort (unique(procedencia)),
                       h.prom = tapply(H14, procedencia, mean, na.rm = T),
                       db.prom= tapply(DB14, procedencia, mean, na.rm = T),
                       dap.prom = tapply(DAP14, procedencia, mean, na.rm = T),
                       dc.prom = tapply(DC14, procedencia, mean, na.rm = T),
                       ac.prom = tapply(AC14, procedencia, mean, na.rm = T)
                       )
                  )
head(prom.proc.MZO,9)
##      procedencia    h.prom  db.prom dap.prom  dc.prom  ac.prom
## IJO          IJO 10.404762 18.96286 15.67238 4.230000 15.09476
## LMCO        LMCO 10.695652 19.01565 15.45957 4.076087 14.39304
## MZO          MZO 10.214286 19.97905 16.30952 4.232381 15.27714
## RNC          RNC  9.738095 17.70333 14.43048 4.011429 13.58143
## SMAO        SMAO  9.972222 19.02889 15.12000 4.118333 14.22222
## SMPO        SMPO 10.420000 20.79160 16.76760 4.456400 16.70680
## TPO          TPO 10.270833 19.41667 15.79542 4.135833 14.41292
## XO            XO 10.571429 20.87286 16.97667 4.630952 17.51476
#Para crear graficos de interaccion, siguiente funcion y esta

library(graphics) 
with(SNAMZ, {
            interaction.plot(procedencia, bloque, H14)
        ## order the rows by their mean effect
            rowpos <- factor(procedencia,
                levels = sort.list(tapply(H14, procedencia, mean)))
            interaction.plot(bloque, procedencia,H14,col=1:8,                                  cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lwd=2,lty=1,main="a) Interaction in Magdalena Zahuatlán")
            }
     )

library(agricolae)
## Warning: package 'agricolae' was built under R version 3.1.3

SNAMZ$bloque= factor(SNAMZ$bloque)
p.aov <- aov(H14~procedencia*bloque, data=SNAMZ)
summary(p.aov)
##                    Df Sum Sq Mean Sq F value   Pr(>F)    
## procedencia         7  14.48   2.068   0.882    0.524    
## bloque             11 105.38   9.580   4.087 8.97e-05 ***
## procedencia:bloque 74 155.72   2.104   0.898    0.680    
## Residuals          81 189.87   2.344                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey<-HSD.test(p.aov,"procedencia",alpha=0.05)
head(tukey)
## $statistics
##       Mean       CV  MSerror      HSD r.harmonic
##   10.29885 14.86629 2.344136 1.451215   21.55308
## 
## $parameters
##   Df ntr StudentizedRange
##   81   8         4.400429
## 
## $means
##            H14      std  r Min  Max
## IJO  10.404762 1.271014 21 8.0 12.5
## LMCO 10.695652 1.550214 23 7.0 13.0
## MZO  10.214286 2.205513 21 5.5 13.0
## RNC   9.738095 1.848101 21 5.0 12.5
## SMAO  9.972222 1.509501 18 7.0 13.0
## SMPO 10.420000 1.823915 25 4.0 12.5
## TPO  10.270833 1.268165 24 7.0 12.5
## XO   10.571429 1.494036 21 5.0 12.5
## 
## $comparison
## NULL
## 
## $groups
##    trt     means M
## 1 LMCO 10.695652 a
## 2 XO   10.571429 a
## 3 SMPO 10.420000 a
## 4 IJO  10.404762 a
## 5 TPO  10.270833 a
## 6 MZO  10.214286 a
## 7 SMAO  9.972222 a
## 8 RNC   9.738095 a
par(mfrow=c(2,2),cex=0.6)
bar.err(tukey$means,variation="SD",horiz=FALSE,ylim=c(0,13),bar=FALSE,col="gray",space=0.5, main="Desviación Estandar",ylab="Altura(m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="SE",horiz=FALSE,ylim=c(0,12),bar=FALSE,col="green",space=0.5,main="Error",ylab="Altura(m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="range",ylim=c(0,15),bar=FALSE,col="blue",space=0.5,main="Rangos de valores = Max-Min",ylab="Altura(m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.group(tukey$groups,horiz=FALSE,ylim=c(0,13),density=20,col="black",main="Grupos",ylab="Altura (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#ANALISIS DE TP
OTP1<-read.csv("C:/LUGO/OAXTP.csv", header=T)
SNATP<- OTP1[which(!is.na(OTP1$H14)),] #Elim NA
tapply(SNATP$H14,list(SNATP$procedencia,SNATP$bloque),mean)#PROMEDIO POR BLOQUES
##          1     2     3     4     5     6     7     8     9    10    11
## IJO  12.00 10.00    NA 11.25 10.00 12.00  6.25 11.50 12.00  6.00  8.25
## LMCO  7.00  8.00 11.50    NA  9.75 10.25 13.00 11.75 10.25 12.00 11.25
## MZO  10.50  7.50 10.25    NA 11.75 11.00 11.25 12.00 11.25  8.25 10.25
## RNC  10.50  7.00  5.00  9.75 12.00 11.00 10.50 10.25 10.00 11.00 10.50
## SMAO  9.75 10.75  3.00 10.25  6.75 10.00 12.00 12.50 11.50  8.00 10.00
## SMPO 10.50 10.50 10.50 13.00 10.00 12.25 11.00 10.25 11.00 11.00 10.75
## TPO   9.50  7.50 10.25 11.00 10.50    NA 11.00    NA 11.75  8.50  9.75
## XO    9.50  9.75 10.00 11.25 12.00  3.50 12.00 10.25 11.50 10.50 10.00
##         12
## IJO   8.25
## LMCO 12.25
## MZO   5.00
## RNC   8.25
## SMAO  8.00
## SMPO  9.25
## TPO   7.50
## XO    9.00
#PROMEDIO POR PROCEDENCIAS
prom.proc.TPO <- with(OTP1, data.frame(
                       procedencia = sort (unique(procedencia)),
                       h.prom = tapply(H14, procedencia, mean, na.rm = T),
                       db.prom= tapply(DB14, procedencia, mean, na.rm = T),
                       dap.prom = tapply(DAP14, procedencia, mean, na.rm = T),
                       dc.prom = tapply(DC14, procedencia, mean, na.rm = T),
                       ac.prom = tapply(AC14, procedencia, mean, na.rm = T)
                       )
                  )
head(prom.proc.TPO,9)
##      procedencia    h.prom  db.prom dap.prom  dc.prom  ac.prom
## IJO          IJO  9.842105 22.63316 18.09368 5.488421 25.44895
## LMCO        LMCO 10.842105 22.55053 18.32789 5.637368 27.28211
## MZO          MZO 10.100000 22.32200 17.93650 4.943000 19.94450
## RNC          RNC  9.761905 19.34143 15.68143 4.486190 16.80476
## SMAO        SMAO  9.522727 20.54909 16.71500 4.733182 19.20364
## SMPO        SMPO 10.775000 20.91350 17.27400 5.226500 22.37700
## TPO          TPO  9.842105 20.78263 17.29895 4.901579 19.67368
## XO            XO 10.142857 22.14571 17.81000 5.250952 22.41762
library(graphics)
with(SNATP, {
  interaction.plot(procedencia, bloque, H14)
  interaction.plot(bloque, procedencia, H14, cex.axis = 0.8)
  ## order the rows by their mean effect
  rowpos <- factor(bloque,
                   levels = sort.list(tapply(H14, bloque, mean)))
  interaction.plot(bloque, procedencia,H14, col = 1:8, cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lwd=2,lty = 1,main="b) Interaction in Tlacotepec Plumas")
})


library(agricolae)
SNATP$bloque= factor(SNATP$bloque)
p.aov <- aov(H14~ procedencia*bloque, data = SNATP)
summary(p.aov)
##                    Df Sum Sq Mean Sq F value Pr(>F)  
## procedencia         7   31.9   4.552   1.046  0.408  
## bloque             11  105.2   9.565   2.198  0.024 *
## procedencia:bloque 72  360.9   5.012   1.152  0.277  
## Residuals          70  304.6   4.352                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey<-HSD.test(p.aov,"procedencia",alpha=0.05)
head(tukey)
## $statistics
##       Mean       CV  MSerror      HSD r.harmonic
##   10.09317 20.66837 4.351786 2.057494   20.07088
## 
## $parameters
##   Df ntr StudentizedRange
##   70   8         4.418634
## 
## $means
##            H14      std  r Min  Max
## IJO   9.842105 2.743946 19 3.0 13.0
## LMCO 10.842105 1.803181 19 7.0 13.0
## MZO  10.100000 2.309021 20 5.0 12.0
## RNC   9.761905 2.477998 21 3.0 12.5
## SMAO  9.522727 2.692482 22 3.0 12.5
## SMPO 10.775000 1.129450 20 8.5 13.0
## TPO   9.842105 2.179785 19 4.5 12.0
## XO   10.142857 2.128044 21 3.5 13.5
## 
## $comparison
## NULL
## 
## $groups
##    trt     means M
## 1 LMCO 10.842105 a
## 2 SMPO 10.775000 a
## 3 XO   10.142857 a
## 4 MZO  10.100000 a
## 5 IJO   9.842105 a
## 6 TPO   9.842105 a
## 7 RNC   9.761905 a
## 8 SMAO  9.522727 a
par(mfrow=c(2,2),cex=0.6)

bar.err(tukey$means,variation="SD",horiz=FALSE,ylim=c(0,15),bar=FALSE,col="gray",space=0.5, main="Desviación Estandar",ylab="Altura (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="SE",horiz=FALSE,ylim=c(0,15),bar=FALSE,col="green",space=0.5,main="Error",ylab="Altura (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="range",ylim=c(0,15),bar=FALSE,col="blue", space=0.5,main="Rangos de valores = Max - Min",ylab="Altura (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.group(tukey$groups,horiz=FALSE,ylim=c(0,15),density=20,col="black",main="Grupos",ylab="Altura (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

OAXT<-read.csv("C:/LUGO/oaxtod.csv", header=T)
PO<- OAXT[which(!is.na(OAXT$H14)),] #Eliminar NA
tapply(PO$H14,list(PO$procedencia,PO$bloque),mean)#PROMEDIO POR BLOQUES
##              1        2         3        4        5        6        7
## IJO  10.666667 11.12500 10.500000 11.00000 11.16667 11.50000  8.00000
## LMCO  7.666667 10.33333 11.125000 10.50000 10.37500  9.87500 11.16667
## MZO  10.000000  8.62500 10.625000 10.25000 10.75000 10.50000 11.87500
## RNC   8.750000  8.00000  7.666667 10.12500 10.87500 11.66667 11.33333
## SMAO  8.875000 10.62500  6.666667 10.75000  6.75000 10.00000 12.12500
## SMPO  8.500000 11.25000 10.000000 11.66667 10.66667 11.25000 11.66667
## TPO  10.000000  8.75000 10.625000 10.00000 11.12500 10.00000 11.00000
## XO    9.125000  9.75000 10.666667 11.50000 11.16667  7.25000 11.25000
##             8         9        10        11        12
## IJO  11.12500 10.625000  9.333333  8.333333  8.875000
## LMCO 11.87500 11.125000 11.750000 11.000000 11.375000
## MZO  11.66667  9.625000 10.250000 10.250000  5.750000
## RNC   9.00000  9.833333 10.833333 10.250000  9.166667
## SMAO 10.33333 11.000000  9.250000 10.000000  8.333333
## SMPO 10.62500 10.375000 11.125000 11.250000  9.125000
## TPO   9.50000 10.625000  9.875000  9.375000  9.666667
## XO   10.87500 10.750000 10.375000 10.500000  9.500000
#PROMEDIO POR PROCEDENCIAS

prom.procTO <- with(OAXT, data.frame(
                       procedencia = sort (unique(procedencia)),
                       h.prom = tapply(H14, procedencia, mean, na.rm = T),
                       db.prom= tapply(DB14, procedencia, mean, na.rm = T),
                       dap.prom = tapply(DAP14, procedencia, mean, na.rm = T),
                       dc.prom = tapply(DC14, procedencia, mean, na.rm = T),
                       ac.prom = tapply(AC14, procedencia, mean, na.rm = T)
                       )
                  )
head(prom.procTO,9)
##      procedencia   h.prom  db.prom dap.prom  dc.prom  ac.prom
## IJO          IJO 10.13750 20.70625 16.82250 4.827750 20.01300
## LMCO        LMCO 10.76190 20.61476 16.75714 4.782381 20.22381
## MZO          MZO 10.15854 21.12195 17.10317 4.579024 17.55390
## RNC          RNC  9.75000 18.52238 15.05595 4.248810 15.19310
## SMAO        SMAO  9.72500 19.86500 15.99725 4.456500 16.96200
## SMPO        SMPO 10.57778 20.84578 16.99267 4.798667 19.22689
## TPO          TPO 10.08140 20.02023 16.45977 4.474186 16.73744
## XO            XO 10.35714 21.50929 17.39333 4.940952 19.96619
#promedios de las localidades 
prom.locTO <- with(OAXT, data.frame(
                       Localidad = sort (unique(Localidad)),
                       h.prom = tapply(H14, Localidad, mean, na.rm = T),
                       db.prom= tapply(DB14, Localidad, mean, na.rm = T),
                       dap.prom = tapply(DAP14, Localidad, mean, na.rm = T),
                       dc.prom = tapply(DC14, Localidad, mean, na.rm = T),
                       ac.prom = tapply(AC14, Localidad, mean, na.rm = T)
                       )
                  )
head(prom.locTO,9)
##                               Localidad   h.prom  db.prom dap.prom
## Magdalena Zahuatlan Magdalena Zahuatlan 10.29885 19.50316 15.84586
## Tlacotepec Plumas     Tlacotepec Plumas 10.09317 21.37503 17.36615
##                      dc.prom  ac.prom
## Magdalena Zahuatlan 4.239943 15.18075
## Tlacotepec Plumas   5.071553 21.54205
library(graphics)
with(PO, {
  interaction.plot(procedencia, Localidad, H14, col=1:2,cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lty = 1,lwd=2,main="a) Interaction of the localities evaluated")
  ## order the rows by their mean effect
  rowpos <- factor(procedencia,
                   levels = sort.list(tapply(H14, procedencia, mean)))
  interaction.plot(Localidad, procedencia,H14, col = 1:8,cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lwd=2,lty = 1,main="b) Interaction of the provenances in the two localities")
})

library(agricolae)
PO$bloque= factor(PO$bloque)
p.aov <- aov(H14~ Localidad+procedencia+bloque+Localidad:procedencia+procedencia:bloque+Localidad:bloque+Localidad:procedencia:bloque, data = PO)
summary(p.aov)
##                               Df Sum Sq Mean Sq F value  Pr(>F)   
## Localidad                      1    3.5   3.538   1.080 0.30030   
## procedencia                    7   38.1   5.442   1.662 0.12254   
## bloque                        11  110.1  10.012   3.057 0.00101 **
## Localidad:procedencia          7    9.3   1.335   0.408 0.89639   
## procedencia:bloque            77  317.4   4.123   1.259 0.11611   
## Localidad:bloque              11   92.8   8.434   2.576 0.00506 **
## Localidad:procedencia:bloque  69  205.8   2.982   0.911 0.66498   
## Residuals                    151  494.5   3.275                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey<-HSD.test(p.aov,"procedencia",alpha=0.05)
head(tukey)
## $statistics
##   Mean       CV  MSerror      HSD r.harmonic
##   10.2 17.74167 3.274834 1.216491   41.81982
## 
## $parameters
##    Df ntr StudentizedRange
##   151   8         4.347156
## 
## $means
##           H14      std  r Min  Max
## IJO  10.13750 2.093909 40 3.0 13.0
## LMCO 10.76190 1.649974 42 7.0 13.0
## MZO  10.15854 2.228898 41 5.0 13.0
## RNC   9.75000 2.159070 42 3.0 12.5
## SMAO  9.72500 2.224427 40 3.0 13.0
## SMPO 10.57778 1.548297 45 4.0 13.0
## TPO  10.08140 1.721469 43 4.5 12.5
## XO   10.35714 1.828920 42 3.5 13.5
## 
## $comparison
## NULL
## 
## $groups
##    trt    means M
## 1 LMCO 10.76190 a
## 2 SMPO 10.57778 a
## 3 XO   10.35714 a
## 4 MZO  10.15854 a
## 5 IJO  10.13750 a
## 6 TPO  10.08140 a
## 7 RNC   9.75000 a
## 8 SMAO  9.72500 a
par(mfrow=c(2,2),cex=0.6)

bar.err(tukey$means,variation="SD",horiz=FALSE,ylim=c(0,14),bar=FALSE,col="gray",space=0.5,main="Desviación Estandar",ylab="Altura (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="SE",horiz=FALSE,ylim=c(0,12),bar=FALSE,col="green",space=0.5,main="Error",ylab="Altura (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="range",ylim=c(0,14),bar=FALSE,col="blue", space=0.5,main="Rangos de valores = Max - Min",ylab="Altura (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.group(tukey$groups,horiz=FALSE,ylim=c(0,13),density=20,col="black",main="Grupos",ylab="Altura (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

boxplot(PO$H14 ~ PO$Localidad, xlab = "Localidad", ylab = "Altura (m)")

ANOVA EN DIAMETRO BASAL

OMZ1<-read.csv("C:/LUGO/OAXMZ.csv", header=T)
SNAMZ<- OMZ1[which(!is.na(OMZ1$DB14)),] #Eliminar NA
tapply(SNAMZ$DB14,list(SNAMZ$procedencia,SNAMZ$bloque),mean)#PROMEDIO POR BLOQUES
##           1      2      3      4      5      6      7      8      9     10
## IJO  17.830 21.645 19.735 19.415 24.350 15.600 13.050 22.760 12.735 19.895
## LMCO 10.985 21.485 17.350 19.100 20.690 16.710 16.390 24.190 23.555 23.555
## MZO  14.960 16.715 23.400 20.210 18.140 16.710 21.170 18.780 19.580 26.105
## RNC  13.685 15.755 15.600 20.690 14.165 23.395 22.600 14.005 16.550 17.190
## SMAO 15.120 20.215 15.755 24.830     NA 17.670 21.805 17.030 21.010 21.170
## SMPO 16.075 25.780 13.850 21.800 18.935 22.915 21.805 23.240 16.075 28.485
## TPO  21.800 17.665 22.125 18.145 25.940 14.485 19.095 18.780 17.190 20.690
## XO   18.460     NA 18.465 21.805 24.670 15.600 19.740 23.080 20.690 21.010
##           11     12
## IJO  21.0100 18.305
## LMCO 14.3250 19.895
## MZO  22.1250 17.510
## RNC  20.0500 18.140
## SMAO      NA 14.320
## SMPO 23.2375 17.350
## TPO  16.3950 20.690
## XO   23.0750 20.370
library(graphics)
with(SNAMZ, {
  interaction.plot(procedencia, bloque, DB14)
  ## order the rows by their mean effect
  rowpos <- factor(procedencia,
                   levels = sort.list(tapply(DB14, procedencia, mean)))
  interaction.plot(bloque, procedencia,DB14,col=1:8, cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lwd=2,lty=1,main="a) Interaction in Magdalena Zahuatlán")
})

library(agricolae)
SNAMZ$bloque= factor(SNAMZ$bloque)
modelo <- aov(DB14~bloque*procedencia,data=SNAMZ)#Modelo Bloque Completos al Azar
summary(modelo)
##                    Df Sum Sq Mean Sq F value Pr(>F)  
## bloque             11  462.3   42.02   1.782 0.0706 .
## procedencia         7  158.0   22.57   0.957 0.4679  
## bloque:procedencia 74 1516.7   20.50   0.869 0.7290  
## Residuals          81 1909.8   23.58                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey<-HSD.test(modelo,"procedencia",alpha=0.05)# Modelo de Tukey para las procedencias
head(tukey)
## $statistics
##       Mean       CV  MSerror      HSD r.harmonic
##   19.50316 24.89699 23.57782 4.602483   21.55308
## 
## $parameters
##   Df ntr StudentizedRange
##   81   8         4.400429
## 
## $means
##          DB14      std  r   Min   Max
## IJO  18.96286 4.539296 21  7.64 27.37
## LMCO 19.01565 5.519016 23  9.87 26.74
## MZO  19.97905 4.735249 21  9.55 27.06
## RNC  17.70333 4.608176 21  8.91 24.19
## SMAO 19.02889 4.411461 18 11.14 25.78
## SMPO 20.79160 5.752180 25 10.19 35.01
## TPO  19.41667 4.601378 24 10.19 26.10
## XO   20.87286 3.936646 21 10.50 26.74
## 
## $comparison
## NULL
## 
## $groups
##    trt    means M
## 1 XO   20.87286 a
## 2 SMPO 20.79160 a
## 3 MZO  19.97905 a
## 4 TPO  19.41667 a
## 5 SMAO 19.02889 a
## 6 LMCO 19.01565 a
## 7 IJO  18.96286 a
## 8 RNC  17.70333 a
par(mfrow=c(2,2),cex=0.6)
bar.err(tukey$means,variation="SD",horiz=FALSE,ylim=c(0,30),bar=FALSE,col="gray",space=0.5, main="Desviación Estandar",ylab="Diámetro Basal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="SE",horiz=FALSE,ylim=c(0,25),bar=FALSE,col="green",space=0.5,main="Error",ylab="Diámetro Basal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="range",ylim=c(0,35),bar=FALSE,col="blue", space=0.5,main="Rangos de valores = Max - Min",ylab="Diámetro Basal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.group(tukey$groups,horiz=FALSE,ylim=c(0,25),density=8,col="black",main="Grupos",ylab="Diámetro Basal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#ANALISIS DE TP
OTP1<-read.csv("C:/LUGO/OAXTP.csv", header=T)
SNATP<- OTP1[which(!is.na(OTP1$DB14)),] #Eliminar NA
tapply(SNATP$DB14,list(SNATP$procedencia,SNATP$bloque),mean)#PROMEDIO POR BLOQUES
##          1      2     3      4      5      6      7      8      9     10
## IJO  28.17 21.645    NA 25.145 19.100 28.970 11.460 20.690 28.805 14.320
## LMCO 12.10 26.420 22.92     NA 22.125 17.670 28.330 22.760 19.735 20.850
## MZO  24.99 23.240 20.77     NA 26.105 16.870 18.460 24.510 23.235 25.945
## RNC  18.78 10.825 11.14 17.030 21.645 21.010 17.190 20.055 18.620 26.260
## SMAO 20.21 22.920  6.78 23.870 11.455 26.420 23.875 23.870 22.920 20.850
## SMPO 14.80 20.690 17.19 23.240 17.190 27.375 27.060 21.170 20.375 21.325
## TPO  17.67 19.100 20.77 25.145 22.120     NA 21.805     NA 26.100 17.825
## XO   18.46 21.490 22.60 23.555 21.330  8.910 21.805 20.690 25.145 26.260
##          11     12
## IJO  21.960 25.945
## LMCO 25.780 28.965
## MZO  21.325 12.410
## RNC  21.805 23.395
## SMAO 14.480 23.715
## SMPO 22.440 20.370
## TPO  21.805 10.190
## XO   22.445 26.260
library(graphics)
with(SNATP, {
  interaction.plot(procedencia, bloque, DB14)
  ## order the rows by their mean effect
  rowpos <- factor(procedencia,
                   levels = sort.list(tapply(DB14, procedencia, mean)))
  interaction.plot(bloque, procedencia,DB14,col=1:8, cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lwd=2,lty=1,main="a) Interaction in Tlacotepec Plumas")
})

library(agricolae)
SNATP$bloque= factor(SNATP$bloque)
modelo <- aov(DB14~bloque*procedencia, data=SNATP)#Modelo Bloque Completos al Azar
summary(modelo)
##                    Df Sum Sq Mean Sq F value Pr(>F)  
## bloque             11  280.6   25.51   1.013 0.4446  
## procedencia         7  211.6   30.23   1.200 0.3143  
## bloque:procedencia 72 2623.7   36.44   1.447 0.0614 .
## Residuals          70 1763.2   25.19                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey<-HSD.test(modelo,"procedencia", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukey)
## $statistics
##       Mean       CV  MSerror      HSD r.harmonic
##   21.37503 23.47969 25.18826 4.949985   20.07088
## 
## $parameters
##   Df ntr StudentizedRange
##   70   8         4.418634
## 
## $means
##          DB14      std  r   Min   Max
## IJO  22.63316 6.221647 19  7.32 30.24
## LMCO 22.55053 6.329027 19 11.78 34.38
## MZO  22.32200 5.255003 20 12.41 32.47
## RNC  19.34143 5.602335 21  3.82 27.69
## SMAO 20.54909 6.065514 22  6.78 27.69
## SMPO 20.91350 4.328080 20 14.64 27.69
## TPO  20.78263 5.288376 19  9.55 28.65
## XO   22.14571 4.885960 21  8.91 28.65
## 
## $comparison
## NULL
## 
## $groups
##    trt    means M
## 1 IJO  22.63316 a
## 2 LMCO 22.55053 a
## 3 MZO  22.32200 a
## 4 XO   22.14571 a
## 5 SMPO 20.91350 a
## 6 TPO  20.78263 a
## 7 SMAO 20.54909 a
## 8 RNC  19.34143 a
par(mfrow=c(2,2),cex=0.6)

bar.err(tukey$means,variation="SD",horiz=FALSE,ylim=c(0,30),bar=FALSE,col="gray",space=0.5, main="Desviación Estandar",ylab="Diámetro Basal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="SE",horiz=FALSE,ylim=c(0,25),bar=FALSE,col="green",space=0.5,main="Error",ylab="Diámetro Basal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="range",ylim=c(0,35),bar=FALSE,col="blue", space=0.5,main="Rangos de valores = Max - Min",ylab="Diámetro Basal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.group(tukey$groups,horiz=FALSE,ylim=c(0,30),density=20,col="black",main="Grupos",ylab="Diámetro Basal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

PO<-read.csv("C:/LUGO/oaxtod.csv", header=T)
POH<- PO[which(!is.na(PO$DB14)),] #Eliminar NA
tapply(POH$DB14,list(POH$procedencia,POH$bloque),mean)#PROMEDIO POR BLOQUES
##             1       2        3      4        5        6        7      8
## IJO  24.72333 21.6450 19.73500 22.280 22.60000 22.28500 12.25500 21.725
## LMCO 11.35667 23.1300 20.13500 19.100 21.40750 17.19000 20.37000 23.475
## MZO  21.64667 19.9775 22.08500 20.210 22.12250 16.76333 19.81500 22.600
## RNC  16.23250 13.2900 14.11333 18.860 17.90500 22.60000 20.79667 17.030
## SMAO 17.66500 21.5675 12.76333 24.350 11.45500 22.04500 22.84000 19.310
## SMPO 15.43750 23.2350 15.52000 22.280 18.35333 25.14500 23.55667 22.205
## TPO  19.73500 18.3825 21.44750 21.645 24.03000 14.48500 20.45000 18.780
## XO   18.46000 21.4900 19.84333 22.680 23.55667 12.25500 20.77250 21.885
##             9       10       11       12
## IJO  20.77000 18.03667 21.64333 22.12500
## LMCO 21.64500 22.20250 20.05250 24.43000
## MZO  21.40750 26.02500 21.72500 14.96000
## RNC  17.93000 23.23667 20.92750 21.64333
## SMAO 22.28333 21.01000 14.48000 20.58333
## SMPO 18.22500 24.90500 22.97167 18.86000
## TPO  21.64500 19.25750 19.10000 17.19000
## XO   22.91750 23.63500 22.76000 23.31500
library(graphics)
with(POH, {
  interaction.plot(procedencia, Localidad, DB14, col=1:2,cex.axis=1.2,cex.lab=1.5,cex.main=1.5,lty = 1,lwd=2,main="a) Interaction of the localities evaluated")
  ## order the rows by their mean effect
  rowpos <- factor(procedencia,
                   levels = sort.list(tapply(DB14, procedencia, mean)))
  interaction.plot(Localidad, procedencia,DB14, col = 1:8,cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lwd=2,lty = 1,main="b) Interaction of the provenances in the two localities")
})

library(agricolae)
POH$bloque= factor(POH$bloque)
modelo <- aov(DB14~Localidad+procedencia+bloque+Localidad:procedencia+Localidad:bloque+procedencia:bloque+Localidad:procedencia:bloque, data=POH)
summary(modelo)
##                               Df Sum Sq Mean Sq F value   Pr(>F)    
## Localidad                      1    293  293.01  12.046 0.000677 ***
## procedencia                    7    264   37.65   1.548 0.155403    
## bloque                        11    478   43.44   1.786 0.060909 .  
## Localidad:procedencia          7    106   15.15   0.623 0.736492    
## Localidad:bloque              11    265   24.09   0.990 0.457698    
## procedencia:bloque            77   2435   31.62   1.300 0.086956 .  
## Localidad:procedencia:bloque  69   1706   24.72   1.016 0.458418    
## Residuals                    151   3673   24.32                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey<-HSD.test(modelo,"procedencia", alpha=0.05)
head(tukey)
## $statistics
##       Mean       CV  MSerror      HSD r.harmonic
##   20.40278 24.17306 24.32438 3.315393   41.81982
## 
## $parameters
##    Df ntr StudentizedRange
##   151   8         4.347156
## 
## $means
##          DB14      std  r   Min   Max
## IJO  20.70625 5.646053 40  7.32 30.24
## LMCO 20.61476 6.091056 42  9.87 34.38
## MZO  21.12195 5.072896 41  9.55 32.47
## RNC  18.52238 5.133829 42  3.82 27.69
## SMAO 19.86500 5.374001 40  6.78 27.69
## SMPO 20.84578 5.112774 45 10.19 35.01
## TPO  20.02023 4.904233 43  9.55 28.65
## XO   21.50929 4.429412 42  8.91 28.65
## 
## $comparison
## NULL
## 
## $groups
##    trt    means M
## 1 XO   21.50929 a
## 2 MZO  21.12195 a
## 3 SMPO 20.84578 a
## 4 IJO  20.70625 a
## 5 LMCO 20.61476 a
## 6 TPO  20.02023 a
## 7 SMAO 19.86500 a
## 8 RNC  18.52238 a
par(mfrow=c(2,2),cex=0.6)

bar.err(tukey$means,variation="SD",horiz=FALSE,ylim=c(0,30),bar=FALSE,col="gray",space=0.5, main="Desviación Estandar",ylab="Diámetro Basal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="SE",horiz=FALSE,ylim=c(0,25),bar=FALSE,col="green",space=0.5,main="Error",ylab="Diámetro Basal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="range",ylim=c(0,35),bar=FALSE,col="blue", space=0.5,main="Rangos de valores = Max - Min",ylab="Diámetro Basal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.group(tukey$groups,horiz=FALSE,ylim=c(0,40),density=20,col="black",main="Grupos",ylab="Diámetro Basal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

boxplot(POH$DB14 ~ POH$Localidad, xlab = "Localidad", ylab = "Diamétro Basal (cm)")

ANOVA EN DIAMETRO NORMAL

OMZ1<-read.csv("C:/LUGO/OAXMZ.csv", header=T)
SNAMZ<- OMZ1[which(!is.na(OMZ1$DAP14)),] #Eliminar NA
tapply(SNAMZ$DAP14,list(SNAMZ$procedencia,SNAMZ$bloque),mean)#PROMEDIO POR BLOQUES
##           1      2      3      4      5      6      7      8      9     10
## IJO  14.320 19.255 14.485 15.440 18.780 15.280 10.505 20.530 10.500 16.870
## LMCO  7.480 18.465 13.850 15.280 17.190 11.615 13.525 19.420 20.215 20.850
## MZO  11.780 13.525 19.735 16.870 13.050 13.370 17.350 14.640 16.075 22.440
## RNC   9.865 12.575 12.575 16.715 10.025 21.010 18.620 10.665 16.230 14.640
## SMAO 10.345 16.395 14.005 20.535     NA 13.845 17.665 13.845 15.920 16.075
## SMPO  9.390 23.550 10.820 18.460 16.075 17.825 17.670 20.215 12.890 21.960
## TPO  18.300 14.960 17.985 11.620 23.555 11.615 15.755 14.320 14.010 18.300
## XO   14.325     NA 14.640 19.260 18.940 12.100 16.390 20.690 16.390 16.395
##          11     12
## IJO  16.550 15.120
## LMCO 11.620 15.915
## MZO  18.940 13.370
## RNC  16.075 15.920
## SMAO     NA 10.820
## SMPO 19.495 13.525
## TPO  12.730 16.395
## XO   18.940 16.235
library(graphics)
with(SNAMZ, {
  interaction.plot(procedencia, bloque, DAP14)
  ## order the rows by their mean effect
  rowpos <- factor(procedencia,
                   levels = sort.list(tapply(DAP14, procedencia, mean)))
  interaction.plot(bloque, procedencia,DAP14,col=1:8, cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lwd=2,lty=1,main="a) Interaction in Magdalena Zahuatlán")
})

library(agricolae)
SNAMZ$bloque= factor(SNAMZ$bloque)
modelo <- aov(DAP14~bloque*procedencia, data=SNAMZ)#Modelo Bloque Completos al Azar
summary(modelo)
##                    Df Sum Sq Mean Sq F value Pr(>F)  
## bloque             11  465.3   42.30   1.867 0.0562 .
## procedencia         7  100.5   14.35   0.633 0.7270  
## bloque:procedencia 74 1483.1   20.04   0.884 0.7034  
## Residuals          81 1835.5   22.66                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey<-HSD.test(modelo,"procedencia")# Modelo de Tukey para las procedencias
head(tukey)
## $statistics
##       Mean       CV  MSerror      HSD r.harmonic
##   15.84586 30.04104 22.66009 4.512021   21.55308
## 
## $parameters
##   Df ntr StudentizedRange
##   81   8         4.400429
## 
## $means
##         DAP14      std  r  Min   Max
## IJO  15.67238 4.094027 21 6.68 23.87
## LMCO 15.45957 5.451187 23 5.09 23.24
## MZO  16.30952 5.109541 21 5.09 22.60
## RNC  14.43048 4.509964 21 5.41 21.33
## SMAO 15.12000 3.813289 18 7.32 21.65
## SMPO 16.76760 5.811409 25 5.73 29.28
## TPO  15.79542 4.679651 24 5.41 25.15
## XO   16.97667 3.851568 21 6.37 22.28
## 
## $comparison
## NULL
## 
## $groups
##    trt    means M
## 1 XO   16.97667 a
## 2 SMPO 16.76760 a
## 3 MZO  16.30952 a
## 4 TPO  15.79542 a
## 5 IJO  15.67238 a
## 6 LMCO 15.45957 a
## 7 SMAO 15.12000 a
## 8 RNC  14.43048 a
par(mfrow=c(2,2),cex=0.6)
bar.err(tukey$means,variation="SD",horiz=FALSE,ylim=c(0,25),bar=FALSE,col="gray",space=0.5, main="Desviación Estandar",ylab="Diámetro Normal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="SE",horiz=FALSE,ylim=c(0,20),bar=FALSE,col="green",space=0.5,main="Error",ylab="Diámetro Normal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="range",ylim=c(0,30),bar=FALSE,col="blue", space=0.5,main="Rangos de valores = Max - Min",ylab="Diámetro Normal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.group(tukey$groups,horiz=FALSE,ylim=c(0,20),density=8,col="black",main="Grupos",ylab="Diámetro Normal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#ANALISIS DE TP
OTP1<-read.csv("C:/LUGO/OAXTP.csv", header=T)
SNATP<- OTP1[which(!is.na(OTP1$DAP14)),] #Eliminar NA
tapply(SNATP$DAP14,list(SNATP$procedencia,SNATP$bloque),mean)#PROMEDIO POR BLOQUES
##           1      2      3      4      5      6      7      8      9     10
## IJO  23.715 17.510     NA 19.735 15.600 25.780  8.275 16.870 21.960 10.820
## LMCO  8.590 22.280 18.780     NA 17.985 14.320 23.240 18.940 15.915 16.715
## MZO  21.805 18.940 16.710     NA 21.965 14.010 14.960 20.050 15.915 20.850
## RNC  15.755  8.755  5.890 13.050 17.510 17.510 14.010 17.030 14.960 21.960
## SMAO 16.075 18.940  2.930 18.145  8.120 21.965 20.530 21.650 18.780 17.190
## SMPO 11.775 17.190 14.230 22.280 15.280 22.440 21.330 17.345 16.395 17.825
## TPO  15.120 14.320 16.475 20.850 17.190     NA 20.055     NA 22.920 14.805
## XO   15.280 18.620 13.370 19.575 16.550  5.410 17.985 16.395 20.210 20.530
##          11     12
## IJO  17.510 20.215
## LMCO 22.440 21.965
## MZO  17.505  7.320
## RNC  17.510 19.420
## SMAO 11.460 20.370
## SMPO 17.505 17.185
## TPO  18.625  7.960
## XO   19.420 21.325
library(graphics)
with(SNATP, {
  interaction.plot(procedencia, bloque, DAP14)
  ## order the rows by their mean effect
  rowpos <- factor(procedencia,
                   levels = sort.list(tapply(DAP14, procedencia, mean)))
  interaction.plot(bloque, procedencia,DAP14,col=1:8, cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lwd=2,lty=1,main="a) Interaction in Tlacotepec Plumas")
})


library(agricolae)
SNATP$bloque= factor(SNATP$bloque)
modelo <- aov(DAP14~bloque*procedencia,data=SNATP)#Modelo Bloque Completos al Azar
summary(modelo)
##                    Df Sum Sq Mean Sq F value Pr(>F)
## bloque             11  218.0   19.82   0.814  0.626
## procedencia         7  120.8   17.25   0.709  0.665
## bloque:procedencia 72 2244.5   31.17   1.280  0.150
## Residuals          70 1704.2   24.35
tukey<-HSD.test(modelo,"procedencia", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukey)
## $statistics
##       Mean       CV  MSerror      HSD r.harmonic
##   17.36615 28.41275 24.34633 4.866555   20.07088
## 
## $parameters
##   Df ntr StudentizedRange
##   70   8         4.418634
## 
## $means
##         DAP14      std  r   Min   Max
## IJO  18.09368 5.547089 19  4.14 25.78
## LMCO 18.32789 5.822619 19  8.28 27.69
## MZO  17.93650 5.310377 20  7.32 28.65
## RNC  15.68143 5.346947 21  1.59 22.92
## SMAO 16.71500 5.676584 22  2.93 24.51
## SMPO 17.27400 3.650431 20 11.14 22.60
## TPO  17.29895 5.338996 19  4.77 23.87
## XO   17.81000 4.823708 21  5.41 24.51
## 
## $comparison
## NULL
## 
## $groups
##    trt    means M
## 1 LMCO 18.32789 a
## 2 IJO  18.09368 a
## 3 MZO  17.93650 a
## 4 XO   17.81000 a
## 5 TPO  17.29895 a
## 6 SMPO 17.27400 a
## 7 SMAO 16.71500 a
## 8 RNC  15.68143 a
par(mfrow=c(2,2),cex=0.6)

bar.err(tukey$means,variation="SD",horiz=FALSE,ylim=c(0,25),bar=FALSE,col="gray",space=0.5, main="Desviación Estandar",ylab="Diámetro Normal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="SE",horiz=FALSE,ylim=c(0,20),bar=FALSE,col="green",space=0.5,main="Error",ylab="Diámetro Normal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="range",ylim=c(0,30),bar=FALSE,col="blue", space=0.5,main="Rangos de valores = Max - Min",ylab="Diámetro Normal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.group(tukey$groups,horiz=FALSE,ylim=c(0,25),density=20,col="black",main="Grupos",xlab="Procedencias",ylab="Diámetro Normal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

PO<-read.csv("C:/LUGO/oaxtod.csv", header=T)
POH<- PO[which(!is.na(PO$DAP14)),] #Eliminar NA
tapply(POH$DAP14,list(POH$procedencia,POH$bloque),mean)#PROMEDIO POR BLOQUES
##             1        2        3        4        5        6        7
## IJO  20.58333 18.38250 14.48500 17.58750 17.72000 20.53000  9.39000
## LMCO  7.85000 19.73667 16.31500 15.28000 17.58750 12.96750 16.76333
## MZO  18.46333 16.23250 18.22250 16.87000 17.50750 13.58333 16.15500
## RNC  12.81000 10.66500 10.34667 14.88250 13.76750 19.84333 17.08333
## SMAO 13.21000 17.66750 10.31333 19.34000  8.12000 17.90500 19.09750
## SMPO 10.58250 20.37000 12.52500 19.73333 15.81000 20.13250 18.89000
## TPO  16.71000 14.64000 17.23000 16.23500 20.37250 11.61500 17.90500
## XO   14.80250 18.62000 14.21667 19.41750 18.14333  8.75500 17.18750
##             8        9       10       11       12
## IJO  18.70000 16.23000 14.85333 17.19000 17.66750
## LMCO 19.18000 18.06500 18.78250 17.03000 18.94000
## MZO  18.24667 15.99500 21.64500 18.22250 10.34500
## RNC  13.84750 15.38333 19.52000 16.79250 18.25333
## SMAO 16.44667 17.82667 16.63250 11.46000 17.18667
## SMPO 18.78000 14.64250 19.89250 18.83167 15.35500
## TPO  14.32000 18.46500 16.55250 15.67750 13.58333
## XO   18.54250 18.30000 18.46250 19.18000 18.78000
library(graphics)
with(POH, {
  interaction.plot(procedencia, Localidad, DAP14, col=1:2,cex.axis=1.2,cex.lab=1.5,cex.main=1.5,lty = 1,lwd=2,main="a) Interaction of the localities evaluated")
  ## order the rows by their mean effect
  rowpos <- factor(procedencia,
                   levels = sort.list(tapply(DAP14, procedencia, mean)))
  interaction.plot(Localidad, procedencia,DAP14, col = 1:8,cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lwd=2,lty = 1,main="b) Interaction of the provenances in the two localities")
})

library(agricolae)
POH$bloque=factor(POH$bloque)
modelo <- aov(DAP14~Localidad+procedencia+bloque+Localidad:procedencia+Localidad:bloque+procedencia:bloque+Localidad:procedencia:bloque,data=POH)
summary(modelo)
##                               Df Sum Sq Mean Sq F value  Pr(>F)   
## Localidad                      1    193  193.28   8.245 0.00467 **
## procedencia                    7    172   24.51   1.046 0.40190   
## bloque                        11    435   39.56   1.687 0.08112 . 
## Localidad:procedencia          7     44    6.29   0.269 0.96523   
## Localidad:bloque              11    254   23.07   0.984 0.46321   
## procedencia:bloque            77   2145   27.86   1.188 0.18447   
## Localidad:procedencia:bloque  69   1583   22.94   0.978 0.53197   
## Residuals                    151   3540   23.44                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey<-HSD.test(modelo,"procedencia", alpha=0.05)
head(tukey)
## $statistics
##       Mean       CV  MSerror      HSD r.harmonic
##   16.57651 29.20804 23.44179 3.254689   41.81982
## 
## $parameters
##    Df ntr StudentizedRange
##   151   8         4.347156
## 
## $means
##         DAP14      std  r  Min   Max
## IJO  16.82250 4.929152 40 4.14 25.78
## LMCO 16.75714 5.737330 42 5.09 27.69
## MZO  17.10317 5.208326 41 5.09 28.65
## RNC  15.05595 4.926344 42 1.59 22.92
## SMAO 15.99725 4.933095 40 2.93 24.51
## SMPO 16.99267 4.923451 45 5.73 29.28
## TPO  16.45977 4.977905 43 4.77 25.15
## XO   17.39333 4.331806 42 5.41 24.51
## 
## $comparison
## NULL
## 
## $groups
##    trt    means M
## 1 XO   17.39333 a
## 2 MZO  17.10317 a
## 3 SMPO 16.99267 a
## 4 IJO  16.82250 a
## 5 LMCO 16.75714 a
## 6 TPO  16.45977 a
## 7 SMAO 15.99725 a
## 8 RNC  15.05595 a
par(mfrow=c(2,2),cex=0.6)

bar.err(tukey$means,variation="SD",horiz=FALSE,ylim=c(0,25),bar=FALSE,col="gray",space=0.5, main="Desviación Estandar",ylab="Diámetro Normal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="SE",horiz=FALSE,ylim=c(0,20),bar=FALSE,col="green",space=0.5,main="Error",ylab="Diámetro Normal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="range",ylim=c(0,30),bar=FALSE,col="blue", space=0.5,main="Rangos de valores = Max - Min",ylab="Diámetro Normal (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
boxplot(POH$DAP14 ~ POH$Localidad, xlab = "Localidad", ylab = "Diámetro Normal (cm)",cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

ANOVA EN DIAMETRO DE COPA

OMZ1<-read.csv("C:/LUGO/OAXMZ.csv",header=T)
SNAMZ<- OMZ1[which(!is.na(OMZ1$DC14)),] #Eliminar NA
tapply(SNAMZ$DC14,list(SNAMZ$procedencia,SNAMZ$bloque),mean)#PROMEDIO POR BLOQUES
##          1     2     3     4     5     6     7     8     9    10     11
## IJO  4.550 4.940 4.175 3.590 5.765 3.750 3.115 5.025 2.725 3.715 6.6500
## LMCO 1.625 5.390 4.600 3.650 4.715 3.775 4.575 4.025 4.050 5.240 3.0050
## MZO  3.850 3.275 4.250 3.975 3.950 3.500 4.750 2.700 4.775 6.000 4.3650
## RNC  2.775 2.965 4.225 4.440 3.150 5.400 5.350 3.600 3.650 4.150 4.2900
## SMAO 3.000 5.125 3.725 5.250    NA 3.740 4.575 3.625 4.700 4.400     NA
## SMPO 3.490 6.480 3.490 5.025 4.675 4.900 5.240 4.290 2.875 5.965 4.0825
## TPO  4.800 4.175 4.450 3.765 5.175 3.275 5.050 2.725 4.050 3.775 3.5150
## XO   4.590    NA 3.550 4.700 5.300 3.730 4.865 5.325 4.225 5.350 4.8400
##         12
## IJO  3.890
## LMCO 4.050
## MZO  4.650
## RNC  4.050
## SMAO 2.550
## SMPO 4.350
## TPO  4.875
## XO   4.015
library(graphics)
with(SNAMZ, {
  interaction.plot(procedencia, bloque, DC14)
  ## order the rows by their mean effect
  rowpos <- factor(procedencia,
                   levels = sort.list(tapply(DC14, procedencia, mean)))
  interaction.plot(bloque, procedencia,DC14,col=1:8, cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lwd=2,lty=1,main="a) Interaction in Magdalena Zahuatlán")
})

library(agricolae)
SNAMZ$bloque= factor(SNAMZ$bloque)
modelo <- aov(DC14~bloque*procedencia,data=SNAMZ)#Modelo Bloque Completos al Azar
summary(modelo)
##                    Df Sum Sq Mean Sq F value Pr(>F)  
## bloque             11  24.86   2.260   1.769 0.0732 .
## procedencia         7   7.13   1.019   0.798 0.5916  
## bloque:procedencia 74  99.73   1.348   1.055 0.4055  
## Residuals          81 103.45   1.277                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey<-HSD.test(modelo,"procedencia", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukey)
## $statistics
##       Mean       CV  MSerror      HSD r.harmonic
##   4.239943 26.65459 1.277215 1.071204   21.55308
## 
## $parameters
##   Df ntr StudentizedRange
##   81   8         4.400429
## 
## $means
##          DC14       std  r  Min  Max
## IJO  4.230000 1.1806566 21 2.20 6.65
## LMCO 4.076087 1.3375070 23 1.00 6.45
## MZO  4.232381 1.2707356 21 1.95 6.55
## RNC  4.011429 1.1231753 21 2.00 5.90
## SMAO 4.118333 1.1018661 18 1.70 6.10
## SMPO 4.456400 1.2123973 25 1.95 6.50
## TPO  4.135833 1.1404992 24 1.78 6.40
## XO   4.630952 0.9474804 21 2.73 6.23
## 
## $comparison
## NULL
## 
## $groups
##    trt    means M
## 1 XO   4.630952 a
## 2 SMPO 4.456400 a
## 3 MZO  4.232381 a
## 4 IJO  4.230000 a
## 5 TPO  4.135833 a
## 6 SMAO 4.118333 a
## 7 LMCO 4.076087 a
## 8 RNC  4.011429 a
par(mfrow=c(2,2),cex=0.6)
bar.err(tukey$means,variation="SD",horiz=FALSE,ylim=c(0,6),bar=FALSE,col="gray",space=0.5, main="Desviación Estandar",ylab="Diámetro de Copa (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="SE",horiz=FALSE,ylim=c(0,5),bar=FALSE,col="green",space=0.5,main="Error",ylab="Diámetro de Copa (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="range",ylim=c(0,7),bar=FALSE,col="blue", space=0.5,main="Rangos de valores = Max - Min",ylab="Diámetro de Copa (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.group(tukey$groups,horiz=FALSE,ylim=c(0,6),density=8,col="black",main="Grupos",ylab="Diámetro de Copa (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#ANALISIS DE TP
OTP1<-read.csv("C:/LUGO/OAXTP.csv", header=T)
SNATP<- OTP1[which(!is.na(OTP1$DC14)),] #Eliminar NA
tapply(SNATP$DC14,list(SNATP$procedencia,SNATP$bloque),mean)#PROMEDIO POR BLOQUES
##          1     2     3    4    5     6     7     8     9    10    11    12
## IJO  8.025 5.250    NA 5.40 4.80 6.150 3.350 5.200 6.890 4.050 4.875 5.650
## LMCO 3.600 6.550 6.115   NA 6.75 4.075 9.450 4.400 6.040 4.700 6.675 5.000
## MZO  5.930 5.100 4.250   NA 6.15 4.450 3.425 5.525 4.300 4.775 5.000 5.500
## RNC  4.090 4.200 2.500 4.30 4.25 5.650 4.000 4.815 3.675 6.025 4.150 5.525
## SMAO 5.025 4.940 2.200 5.05 2.70 5.700 6.375 6.600 3.975 4.975 3.125 5.800
## SMPO 4.415 4.700 4.675 7.10 5.05 6.925 6.700 4.175 5.750 4.675 5.300 4.575
## TPO  5.150 5.675 4.200 5.04 4.50    NA 5.550    NA 6.300 4.125 4.600 2.850
## XO   5.125 4.730 5.000 6.00 4.30 3.150 6.150 4.975 5.275 5.690 5.175 5.790
library(graphics)
with(SNATP, {
  interaction.plot(procedencia, bloque, DC14)
  interaction.plot(bloque, procedencia, DC14, cex.axis = 0.8)
  ## order the rows by their mean effect
  rowpos <- factor(procedencia,
                   levels = sort.list(tapply(DC14, procedencia, mean)))
  interaction.plot(bloque, procedencia,DC14,col=1:8, cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lwd=2,lty=1,main="a) Interaction in Tlacotepec Plumas")
})

library(agricolae)
SNATP$bloque= factor(SNATP$bloque)
modelo <- aov(DC14~bloque*procedencia, data=SNATP)#Modelo Bloque Completos al Azar
summary(modelo)
##                    Df Sum Sq Mean Sq F value  Pr(>F)   
## bloque             11  11.04   1.004   0.821 0.61897   
## procedencia         7  21.84   3.120   2.554 0.02113 * 
## bloque:procedencia 72 156.52   2.174   1.779 0.00823 **
## Residuals          70  85.52   1.222                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey<-HSD.test(modelo,"procedencia", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukey)
## $statistics
##       Mean       CV  MSerror      HSD r.harmonic
##   5.071553 21.79463 1.221746 1.090173   20.07088
## 
## $parameters
##   Df ntr StudentizedRange
##   70   8         4.418634
## 
## $means
##          DC14      std  r  Min  Max
## IJO  5.488421 1.551180 19 2.25 9.05
## LMCO 5.637368 1.766349 19 3.55 9.45
## MZO  4.943000 1.006422 20 2.75 6.63
## RNC  4.486190 1.154844 21 2.50 6.50
## SMAO 4.733182 1.464934 22 1.60 6.85
## SMPO 5.226500 1.112556 20 3.70 7.10
## TPO  4.901579 1.039360 19 2.85 6.60
## XO   5.250952 1.009321 21 3.15 6.70
## 
## $comparison
## NULL
## 
## $groups
##    trt    means  M
## 1 LMCO 5.637368  a
## 2 IJO  5.488421 ab
## 3 XO   5.250952 ab
## 4 SMPO 5.226500 ab
## 5 MZO  4.943000 ab
## 6 TPO  4.901579 ab
## 7 SMAO 4.733182 ab
## 8 RNC  4.486190  b
par(mfrow=c(2,2),cex=0.6)

bar.err(tukey$means,variation="SD",horiz=FALSE,ylim=c(0,8),bar=FALSE,col="gray",space=0.5, main="Desviación Estandar",ylab="Diámetro de Copa (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="SE",horiz=FALSE,ylim=c(0,7),bar=FALSE,col="green",space=0.5,main="Error",ylab="Diámetro de Copa (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="range",ylim=c(0,10),bar=FALSE,col="blue", space=0.5,main="Rangos de valores = Max - Min",ylab="Diámetro de Copa (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.group(tukey$groups,horiz=FALSE,ylim=c(0,8),density=20,col="black",main="Grupos",ylab="Diámetro de Copa (m)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

PO<-read.csv("C:/LUGO/oaxtod.csv", header=T)
POH<- PO[which(!is.na(PO$DC14)),] #Eliminar NA
tapply(POH$DC14,list(POH$procedencia,POH$bloque),mean)#PROMEDIO POR BLOQUES
##             1        2        3        4        5        6        7
## IJO  6.866667 5.095000 4.175000 4.495000 5.443333 4.950000 3.232500
## LMCO 2.283333 5.776667 5.357500 3.650000 5.732500 3.925000 6.200000
## MZO  5.236667 4.187500 4.250000 3.975000 5.050000 3.816667 4.087500
## RNC  3.432500 3.582500 3.650000 4.370000 3.700000 5.483333 4.900000
## SMAO 4.012500 5.032500 3.216667 5.150000 2.700000 4.720000 5.475000
## SMPO 3.952500 5.590000 4.082500 5.716667 4.800000 5.912500 5.726667
## TPO  4.975000 4.925000 4.325000 4.402500 4.837500 3.275000 5.300000
## XO   4.857500 4.730000 4.033333 5.350000 4.966667 3.440000 5.507500
##             8        9       10       11       12
## IJO  5.112500 4.807500 3.826667 5.466667 4.770000
## LMCO 4.212500 5.045000 4.970000 4.840000 4.525000
## MZO  4.583333 4.537500 5.387500 4.682500 5.075000
## RNC  4.207500 3.666667 5.400000 4.220000 5.033333
## SMAO 4.616667 4.216667 4.687500 3.125000 4.716667
## SMPO 4.232500 4.312500 5.320000 4.488333 4.462500
## TPO  2.725000 5.175000 3.950000 4.057500 4.200000
## XO   5.150000 4.750000 5.520000 5.007500 4.902500
library(graphics)
with(POH, {
  interaction.plot(procedencia, Localidad, DC14, col=1:2,cex.axis=1.2,cex.lab=1.5,cex.main=1.5,lty = 1,lwd=2,main="a) Interaction of the localities evaluated")
  ## order the rows by their mean effect
  rowpos <- factor(procedencia,
                   levels = sort.list(tapply(DC14, procedencia, mean)))
  interaction.plot(Localidad, procedencia,DC14, col = 1:8,cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lwd=2,lty = 1,main="b) Interaction of the provenances in the two localities")
})

library(agricolae)
POH$bloque=factor(POH$bloque)
modelo <- aov(DC14~Localidad+procedencia+bloque+Localidad:procedencia+Localidad:bloque+procedencia:bloque+Localidad:procedencia:bloque,data=POH)
summary(modelo)
##                               Df Sum Sq Mean Sq F value   Pr(>F)    
## Localidad                      1  57.83   57.83  46.210 2.31e-10 ***
## procedencia                    7  17.91    2.56   2.044   0.0531 .  
## bloque                        11  15.86    1.44   1.152   0.3256    
## Localidad:procedencia          7  10.48    1.50   1.196   0.3086    
## Localidad:bloque              11  20.63    1.88   1.498   0.1374    
## procedencia:bloque            77 145.75    1.89   1.512   0.0159 *  
## Localidad:procedencia:bloque  69 110.51    1.60   1.280   0.1075    
## Residuals                    151 188.98    1.25                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey<-HSD.test(modelo,"procedencia",alpha=0.05)
head(tukey)
## $statistics
##       Mean       CV  MSerror       HSD r.harmonic
##   4.639612 24.11204 1.251501 0.7520207   41.81982
## 
## $parameters
##    Df ntr StudentizedRange
##   151   8         4.347156
## 
## $means
##          DC14      std  r  Min  Max
## IJO  4.827750 1.493460 40 2.20 9.05
## LMCO 4.782381 1.717051 42 1.00 9.45
## MZO  4.579024 1.190726 41 1.95 6.63
## RNC  4.248810 1.150508 42 2.00 6.50
## SMAO 4.456500 1.334446 40 1.60 6.85
## SMPO 4.798667 1.219026 45 1.95 7.10
## TPO  4.474186 1.150363 43 1.78 6.60
## XO   4.940952 1.016512 42 2.73 6.70
## 
## $comparison
## NULL
## 
## $groups
##    trt    means M
## 1 XO   4.940952 a
## 2 IJO  4.827750 a
## 3 SMPO 4.798667 a
## 4 LMCO 4.782381 a
## 5 MZO  4.579024 a
## 6 TPO  4.474186 a
## 7 SMAO 4.456500 a
## 8 RNC  4.248810 a
par(mfrow=c(2,2),cex=0.6)

bar.err(tukey$means,variation="SD",horiz=FALSE,ylim=c(0,7),bar=FALSE,col="gray",space=0.5, main="Desviación Estandar",ylab="Diámetro de Copa(cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="SE",horiz=FALSE,ylim=c(0,6),bar=FALSE,col="green",space=0.5,main="Error",ylab="Diámetro de Copa (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="range",ylim=c(0,10),bar=FALSE,col="blue", space=0.5,main="Rangos de valores = Max - Min",ylab="Diámetro de Copaa (cm)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
boxplot(POH$DC14 ~ POH$Localidad, xlab = "Localidad", ylab = "Diámetro de Copa (m)",cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

ANOVA DE AREA DE COPA

OMZ1<-read.csv("C:/LUGO/OAXMZ.csv", header=T)
SNAMZ<- OMZ1[which(!is.na(OMZ1$AC14)),] #Eliminar NA
tapply(SNAMZ$AC14,list(SNAMZ$procedencia,SNAMZ$bloque),mean)#PROMEDIO POR BLOQUES
##           1      2      3      4      5      6      7      8      9     10
## IJO  16.260 19.220 14.435 10.125 26.450 11.040  7.660 20.735  6.050 10.875
## LMCO  2.385 23.700 18.155 10.460 18.305 12.020 17.525 12.725 13.515 21.665
## MZO  11.640  8.640 14.235 14.235 15.240 11.510 17.740  5.730 17.950 28.515
## RNC   6.225  6.985 14.690 15.685  8.830 22.950 22.720 10.180 10.460 13.530
## SMAO  8.395 21.375 10.935 21.700     NA 11.310 16.525 10.995 17.350 15.535
## SMPO 10.590 32.980 11.360 19.855 17.340 19.095 21.940 14.460  7.165 28.170
## TPO  18.145 14.515 15.715 14.230 21.210  8.640 21.460  5.870 13.325 11.190
## XO   18.655     NA  9.900 17.360 22.060 10.930 18.600 22.295 14.130 22.765
##          11     12
## IJO  34.730 11.930
## LMCO  7.175 13.120
## MZO  15.170 16.980
## RNC  15.905 12.880
## SMAO     NA  5.110
## SMPO 13.635 15.100
## TPO   9.950 18.705
## XO   18.720 13.955
library(graphics)
with(SNAMZ, {
  interaction.plot(procedencia, bloque, AC14)
  ## order the rows by their mean effect
  rowpos <- factor(procedencia,
                   levels = sort.list(tapply(AC14, procedencia, mean)))
  interaction.plot(bloque, procedencia,AC14,col=1:8, cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lwd=2,lty=1,main="a) Interaction in Magdalena Zahuatlán")
})

library(agricolae)
SNAMZ$bloque= factor(SNAMZ$bloque)
modelo <- aov(AC14~bloque*procedencia, data=SNAMZ)#Modelo Bloque Completos al Azar
summary(modelo)
##                    Df Sum Sq Mean Sq F value Pr(>F)  
## bloque             11   1077   97.92   1.778 0.0715 .
## procedencia         7    296   42.35   0.769 0.6150  
## bloque:procedencia 74   4391   59.33   1.077 0.3708  
## Residuals          81   4461   55.08                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey<-HSD.test(modelo,"procedencia", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukey)
## $statistics
##       Mean       CV  MSerror      HSD r.harmonic
##   15.18075 48.88808 55.07978 7.034552   21.55308
## 
## $parameters
##   Df ntr StudentizedRange
##   81   8         4.400429
## 
## $means
##          AC14      std  r  Min   Max
## IJO  15.09476 8.560475 21 3.80 34.73
## LMCO 14.39304 8.539483 23 0.79 32.67
## MZO  15.27714 8.159417 21 2.99 33.70
## RNC  13.58143 7.198839 21 3.14 27.34
## SMAO 14.22222 6.831753 18 2.27 29.22
## SMPO 16.70680 8.065015 25 2.99 33.18
## TPO  14.41292 7.446001 24 2.49 32.17
## XO   17.51476 6.657772 21 5.85 30.48
## 
## $comparison
## NULL
## 
## $groups
##    trt    means M
## 1 XO   17.51476 a
## 2 SMPO 16.70680 a
## 3 MZO  15.27714 a
## 4 IJO  15.09476 a
## 5 TPO  14.41292 a
## 6 LMCO 14.39304 a
## 7 SMAO 14.22222 a
## 8 RNC  13.58143 a
par(mfrow=c(2,2),cex=0.6)
bar.err(tukey$means,variation="SD",horiz=FALSE,ylim=c(0,26),bar=FALSE,col="gray",space=0.5, main="Desviación Estandar",ylab="Área de Copa (m2)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="SE",horiz=FALSE,ylim=c(0,20),bar=FALSE,col="green",space=0.5,main="Error",ylab="Área de Copa (m2)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="range",ylim=c(0,35),bar=FALSE,col="blue", space=0.5,main="Rangos de valores = Max - Min",ylab=" Área de Copa (m2)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.group(tukey$groups,horiz=FALSE,ylim=c(0,25),density=20,col="black",main="Grupos",ylab="Área de Copa (m2)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

#ANALISIS DE TP
OTP1<-read.csv("C:/LUGO/OAXTP.csv", header=T)
SNATP<- OTP1[which(!is.na(OTP1$AC14)),] #Eliminar NA
tapply(SNATP$AC14,list(SNATP$procedencia,SNATP$bloque),mean)#PROMEDIO POR BLOQUES
##           1      2      3      4      5      6      7      8      9     10
## IJO  51.405 22.355     NA 23.345 18.100 29.710  9.765 21.520 37.575 12.880
## LMCO 10.180 33.700 30.565     NA 39.760 13.260 70.140 15.775 29.800 17.855
## MZO  28.000 20.460 15.135     NA 29.775 15.550  9.570 24.150 14.965 18.085
## RNC  14.445 13.870  4.910 15.025 14.235 25.070 12.570 18.870 10.630 28.685
## SMAO 20.660 19.330  3.800 20.030  6.675 26.020 31.920 34.210 12.410 19.975
## SMPO 15.655 17.350 17.250 39.590 20.030 37.685 35.260 13.865 26.750 17.765
## TPO  20.850 25.765 13.860 20.670 16.770     NA 24.320     NA 31.240 13.580
## XO   22.005 17.730 19.640 28.270 14.520  7.790 29.710 21.780 21.995 25.430
##          11     12
## IJO  20.375 25.080
## LMCO 35.075 20.080
## MZO  19.650 23.760
## RNC  15.295 24.120
## SMAO  7.930 27.285
## SMPO 22.220 16.465
## TPO  16.655  6.380
## XO   21.095 26.395
library(graphics)
with(SNATP, {
  interaction.plot(procedencia, bloque, AC14)
  ## order the rows by their mean effect
  rowpos <- factor(procedencia,
                   levels = sort.list(tapply(AC14, procedencia, mean)))
  interaction.plot(bloque, procedencia,AC14,col=1:8, cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lwd=2,lty=1,main="a) Interaction in Tlacotepec Plumas")
})

library(agricolae)
SNATP$bloque= factor(SNATP$bloque)
modelo <- aov(AC14~bloque*procedencia,data=SNATP)#Modelo Bloque Completos al Azar
summary(modelo)
##                    Df Sum Sq Mean Sq F value  Pr(>F)   
## bloque             11    767   69.73   0.835 0.60629   
## procedencia         7   1703  243.25   2.912 0.00988 **
## bloque:procedencia 72  11080  153.89   1.842 0.00553 **
## Residuals          70   5847   83.54                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey<-HSD.test(modelo,"procedencia", alpha=0.05)# Modelo de Tukey para las procedencias
head(tukey)
## $statistics
##       Mean       CV  MSerror      HSD r.harmonic
##   21.54205 42.42757 83.53536 9.014465   20.07088
## 
## $parameters
##   Df ntr StudentizedRange
##   70   8         4.418634
## 
## $means
##          AC14       std  r   Min   Max
## IJO  25.44895 13.886681 19  3.98 64.33
## LMCO 27.28211 17.503592 19  9.90 70.14
## MZO  19.94450  7.489119 20  5.94 34.52
## RNC  16.80476  8.105737 21  4.91 33.18
## SMAO 19.20364 10.379133 22  2.01 36.85
## SMPO 22.37700  9.618793 20 10.75 39.59
## TPO  19.67368  7.947065 19  6.38 34.21
## XO   22.41762  7.809030 21  7.79 35.26
## 
## $comparison
## NULL
## 
## $groups
##    trt    means  M
## 1 LMCO 27.28211  a
## 2 IJO  25.44895 ab
## 3 XO   22.41762 ab
## 4 SMPO 22.37700 ab
## 5 MZO  19.94450 ab
## 6 TPO  19.67368 ab
## 7 SMAO 19.20364 ab
## 8 RNC  16.80476  b
par(mfrow=c(2,2),cex=0.6)

bar.err(tukey$means,variation="SD",horiz=FALSE,ylim=c(0,50),bar=FALSE,col="gray",space=0.5, main="Desviación Estandar",ylab="Área de Copa (m2)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="SE",horiz=FALSE,ylim=c(0,35),bar=FALSE,col="green",space=0.5,main="Error",ylab="Área de Copa  (m2)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="range",ylim=c(0,75),bar=FALSE,col="blue", space=0.5,main="Rangos de valores = Max - Min",ylab="Área de Copa (m2)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.group(tukey$groups,horiz=FALSE,ylim=c(0,35),density=8,col="black",main="Grupos",ylab="Área de Copa (m2)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

OTP1<-read.csv("C:/LUGO/oaxtod.csv", header=T)
POH<- OTP1[which(!is.na(OTP1$AC14)),] #Eliminar NA
tapply(POH$AC14,list(POH$procedencia,POH$bloque),mean)#PROMEDIO POR BLOQUES
##              1        2         3        4        5        6        7
## IJO  39.690000 20.78750 14.435000 16.73500 23.66667 20.37500  8.71250
## LMCO  4.983333 27.03333 24.360000 10.46000 29.03250 12.64000 35.06333
## MZO  22.546667 14.55000 14.685000 14.23500 22.50750 12.85667 13.65500
## RNC  10.335000 10.42750 11.430000 15.35500 11.53250 23.65667 19.33667
## SMAO 14.527500 20.35250  8.556667 20.86500  6.67500 18.66500 24.22250
## SMPO 13.122500 25.16500 14.305000 26.43333 18.23667 28.39000 26.38000
## TPO  19.497500 20.14000 14.787500 17.45000 18.99000  8.64000 22.89000
## XO   20.330000 17.73000 13.146667 22.81500 19.54667  9.36000 24.15500
##             8        9       10       11       12
## IJO  21.12750 21.81250 11.54333 25.16000 18.50500
## LMCO 14.25000 21.65750 19.76000 21.12500 16.60000
## MZO  18.01000 16.45750 23.30000 17.41000 20.37000
## RNC  14.52500 10.57333 23.63333 15.60000 20.37333
## SMAO 18.73333 14.05667 17.75500  7.93000 19.89333
## SMPO 14.16250 16.95750 22.96750 16.49667 15.78250
## TPO   5.87000 22.28250 12.38500 13.30250 14.59667
## XO   22.03750 18.06250 24.09750 19.90750 20.17500
library(graphics)
with(POH, {
  interaction.plot(procedencia, Localidad, AC14, col=1:2,cex.axis=1.2,cex.lab=1.5,cex.main=1.5,lty = 1,lwd=2,main="a) Interaction of the localities evaluated")
  ## order the rows by their mean effect
  rowpos <- factor(procedencia,
                   levels = sort.list(tapply(AC14, procedencia, mean)))
  interaction.plot(Localidad, procedencia,AC14, col = 1:8,cex.axis=1.5,cex.lab=1.5,cex.main=1.5,lwd=2,lty = 1,main="b) Interaction of the provenances in the two localities")
})


library(agricolae)
POH$bloque=factor(POH$bloque)
modelo <- aov(AC14~Localidad+procedencia+bloque+Localidad:procedencia+Localidad:bloque+procedencia:bloque+Localidad:procedencia:bloque,data=POH)
summary(modelo)
##                               Df Sum Sq Mean Sq F value  Pr(>F)    
## Localidad                      1   3384    3384  49.566 6.3e-11 ***
## procedencia                    7   1133     162   2.371 0.02508 *  
## bloque                        11    838      76   1.116 0.35247    
## Localidad:procedencia          7    828     118   1.733 0.10537    
## Localidad:bloque              11   1044      95   1.390 0.18275    
## procedencia:bloque            77   8483     110   1.614 0.00648 ** 
## Localidad:procedencia:bloque  69   6988     101   1.483 0.02374 *  
## Residuals                    151  10309      68                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tukey<-HSD.test(modelo,"procedencia",alpha=0.05)
head(tukey)
## $statistics
##       Mean       CV  MSerror      HSD r.harmonic
##   18.23797 45.30457 68.27111 5.554342   41.81982
## 
## $parameters
##    Df ntr StudentizedRange
##   151   8         4.347156
## 
## $means
##          AC14       std  r  Min   Max
## IJO  20.01300 12.409844 40 3.80 64.33
## LMCO 20.22381 14.689955 42 0.79 70.14
## MZO  17.55390  8.093714 41 2.99 34.52
## RNC  15.19310  7.745367 42 3.14 33.18
## SMAO 16.96200  9.200552 40 2.01 36.85
## SMPO 19.22689  9.140575 45 2.99 39.59
## TPO  16.73744  8.025975 43 2.49 34.21
## XO   19.96619  7.584542 42 5.85 35.26
## 
## $comparison
## NULL
## 
## $groups
##    trt    means M
## 1 LMCO 20.22381 a
## 2 IJO  20.01300 a
## 3 XO   19.96619 a
## 4 SMPO 19.22689 a
## 5 MZO  17.55390 a
## 6 SMAO 16.96200 a
## 7 TPO  16.73744 a
## 8 RNC  15.19310 a
par(mfrow=c(2,2),cex=0.6)

bar.err(tukey$means,variation="SD",horiz=FALSE,ylim=c(0,40),bar=FALSE,col="gray",space=0.5, main="Desviación Estandar",ylab="Área de Copa(m2)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="SE",horiz=FALSE,ylim=c(0,30),bar=FALSE,col="green",space=0.5,main="Error",ylab="Área de Copa (m2)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.err(tukey$means,variation="range",ylim=c(0,70),bar=FALSE,col="blue", space=0.5,main="Rangos de valores = Max - Min",ylab="Área de Copa (m2)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)
bar.group(tukey$groups,horiz=FALSE,ylim=c(0,35),density=8,col="black",main="Grupos",ylab="Área de Copa (m2)",las=2,cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

boxplot(POH$AC14 ~ POH$Localidad, xlab = "Localidad", ylab = "Área de Copa (m2)",cex.axis=2,cex.lab=1.5,cex.main=2,cex=1.5,font.main=2,font.axis=2)

CORRELACION

library(agricolae)
OMZ1<-read.csv("C:/TESIS/ANOVA/CORR-OAX.csv", header=T)

correlation(OMZ1[,4:8],method="pearson")
## 
## Correlation Analysis
## 
## Method     : pearson
## Alternative: two.sided
## $correlation
##       ALT TEMP  PPTN    PH H.MZ
## ALT  1.00 0.94  0.81  0.02 0.93
## TEMP 0.94 1.00  0.76  0.03 0.94
## PPTN 0.81 0.76  1.00 -0.26 0.75
## PH   0.02 0.03 -0.26  1.00 0.03
## H.MZ 0.93 0.94  0.75  0.03 1.00
## 
## $pvalue
##               ALT         TEMP        PPTN        PH         H.MZ
## ALT  1.0000000000 0.0001718344 0.007530777 0.9632101 0.0003244253
## TEMP 0.0001718344 1.0000000000 0.018137704 0.9419841 0.0001844319
## PPTN 0.0075307773 0.0181377036 1.000000000 0.4758529 0.0189671908
## PH   0.9632101230 0.9419841334 0.475852859 1.0000000 0.9311973048
## H.MZ 0.0003244253 0.0001844319 0.018967191 0.9311973 1.0000000000
## 
## $n.obs
##      ALT TEMP PPTN PH H.MZ
## ALT    9    9    9  9    9
## TEMP   9    9    9  9    9
## PPTN   9    9   10 10    9
## PH     9    9   10 10    9
## H.MZ   9    9    9  9    9
library(psych)
## Warning: package 'psych' was built under R version 3.1.3
pairs.panels(OMZ1[c(2,3,4,5,6,7,8,9,10,11,12)],cex=1,font=2,pch=19,font.labels = 2) #CORRELACIÓN DE VARIABLES EN MZ

pairs.panels(OMZ1[c(2,3,4,5,6,7,13,14,15,16,17)],cex=1,font=2,pch=19,font.labels = 2)#CORRELACIÓN DE VARIABLES EN TP

pairs.panels(OMZ1[c(2,3,4,5,6,7,18,19,20,21,22)],cex=1,font=2,pch=19,font.labels = 2)#CORRELACIÓN DE VARIABLES EN AMBAS

GRAFICAS DE DISTRIBUCION DE PROCEDENCIAS DE ACUERDO AL CRECIMIENTO

OMZ1<-read.csv("C:/LUGO/OAXMZ.csv", header=T)# FACTORES 
OTP1<-read.csv("C:/LUGO/OAXTP.csv", header=T)# FACTORES 

par(mfrow=c(1,2),cex=0.6)
boxplot(H14~procedencia, data=OMZ1)
boxplot(H14~procedencia, data=OTP1)

H14<-OMZ1[c(3,12)]#Seleccion de columnas de interes
plot.design(H14,fun="mean",las=1,cex.axis=2.5,cex.lab=2.5,cex=2.5,font.main=2,ylab="Altura (m)", main="Magdalena Zahuatlán",cex.main=3,ylim=c(9.5,11))
H14<-OTP1[c(3,12)]#Seleccion de columnas de interes
plot.design(H14, fun = "mean",las=1,cex.axis=2.5,cex.lab=2.5,cex=2.5,font.main=2,ylab=" ",main="Tlacotepec Plumas",cex.main=3,ylim=c(9.5,11))

DB14<-OMZ1[c(3,13)]#Seleccion de columnas de interes
plot.design(DB14,fun="mean",las=1,cex.axis=2.5,cex.lab=2.5,cex=2.5,font.main=2,ylab="Diámetro Basal (cm)", main="Magdalena Zahuatlán",cex.main=3,ylim=c(17,23))
DB14<-OTP1[c(3,13)]#Seleccion de columnas de interes
plot.design(DB14,fun="mean",las=1,cex.axis=2.5,cex.lab=2.5,cex=2.5,font.main=2,ylab=" ", main="Tlacotepec Plumas",cex.main=3,ylim=c(17,23))

DAP14<-OMZ1[c(3,14)]#Seleccion de columnas de interes
plot.design(DAP14,fun="mean",las=1,cex.axis=2.5,cex.lab=2.5,cex=2.5,font.main=2,ylab="Diámetro Normal (cm)", main="Magdalena Zahuatlán",cex.main=3,ylim=c(14,19))
DAP14<-OTP1[c(3,14)]#Seleccion de columnas de interes
plot.design(DAP14,fun="mean",las=1,cex.axis=2.5,cex.lab=2.5,cex=2.5,font.main=2,ylab="", main="Tlacotepec Plumas",cex.main=3,ylim=c(14,19))

DC14<-OMZ1[c(3,15)]#Seleccion de columnas de interes
plot.design(DC14,fun="mean",las=1,cex.axis=2.5,cex.lab=2.5,cex=2.5,font.main=2,ylab="Diámetro de Copa (m)", main="Magdalena Zahuatlán",cex.main=3,ylim=c(3.8,5.8))
DC14<-OTP1[c(3,15)]#Seleccion de columnas de interes
plot.design(DC14,fun="mean",las=1,cex.axis=2.5,cex.lab=2.5,cex=2.5,font.main=2,ylab=" " , main="Tlacotepec Plumas",cex.main=3,ylim=c(3.5,5.8))

AC14<-OMZ1[c(3,16)]#Seleccion de columnas de interes
plot.design(AC14,fun="mean",las=1,cex.axis=2.5,cex.lab=2.5,cex=2.5,font.main=2,ylab="Área de Copa (m2/arb)", main="Magdalena Zahuatlán",cex.main=3,ylim=c(13,28))
AC14<-OTP1[c(3,16)]#Seleccion de columnas de interes
plot.design(AC14,fun="mean",las=1,cex.axis=2.5,cex.lab=2.5,cex=2.5,font.main=2,ylab=" ", main="Tlacotepec Plumas",cex.main=3,ylim=c(13,28))

OTO1<-read.csv("C:/LUGO/oaxtod.csv", header=T)# FACTORES 
boxplot(H14~procedencia, data=OTO1)

par(mfrow=c(1,2),cex=0.6)

H14<-OTO1[c(3,12)]#Seleccion de columnas de interes
plot.design(H14,fun="mean",las=1,cex.axis=2.5,cex.lab=2.5,cex=2.5,font.main=2,ylab="m", main="Altura",cex.main=3,ylim=c(9.5,11))
DB14<-OTO1[c(3,13)]#Seleccion de columnas de interes
plot.design(DB14,fun="mean",las=1,cex.axis=2.5,cex.lab=2.5,cex=2.5,font.main=2,ylab=" cm", main="Diámetro Basal",cex.main=3,ylim=c(18,22))

par(mfrow=c(1,3),cex=0.6)
DAP14<-OTO1[c(3,14)]#Seleccion de columnas de interes
plot.design(DAP14,fun="mean",las=1,cex.axis=2.5,cex.lab=2.5,cex=2.5,font.main=2,ylab="cm", main="Diámetro Normal",cex.main=3,ylim=c(14.5,18))
DC14<-OTO1[c(3,15)]#Seleccion de columnas de interes
plot.design(DC14,fun="mean",las=1,cex.axis=2.5,cex.lab=2.5,cex=2.5,font.main=2,ylab="m", main="Diámetro de Copa",cex.main=3,ylim=c(4.2,5))
AC14<-OTO1[c(3,16)]#Seleccion de columnas de interes
plot.design(AC14,fun="mean",las=1,cex.axis=2.5,cex.lab=2.5,cex=2.5,font.main=2,ylab="m2/arb", main="Área de Copa",cex.main=3,ylim=c(14.5,20.5))

SUPERVIVENCIA CON PRUEBA T PARA PRUEBAS INDEPENDIENTES

SUP<-read.csv("C:/TESIS/ANOVA/SUPER.csv", header=T)
boxplot(SUP$SUP.O ~ SUP$LOC.O, xlab = "Contenedores", ylab = "crecimiento (cm)")

t.test(SUP$SUP.O ~ SUP$LOC.O, var.equal=T)#PRUEBA T PARA LAS LOCALIDADES
## 
##  Two Sample t-test
## 
## data:  SUP$SUP.O by SUP$LOC.O
## t = 2.285, df = 14, p-value = 0.03843
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##   0.4378516 13.8371484
## sample estimates:
## mean in group MZ mean in group TP 
##          73.6775          66.5400
boxplot(SUP$SUP.O ~ SUP$PROC.O, xlab = "Contenedores", ylab = "crecimiento (cm)")

tapply(SUP$SUP.O, SUP$PROC.O,mean)#PROMEDIO DE LAS PROCEDENCIAS
##           CMO    IJO    MZO    RNC   SMAO   SMPO    TPO     XO 
##     NA 70.520 66.085 67.590 69.345 69.570 72.025 76.435 69.300
PROCEDENCIAS VALORES ARC VALORES %
CMO 70.520 88.86
IJO 66.085 84.48
MZO 67.590 85.36
RNC 69.345 87.51
SMAO 69.570 87.74
SMPO 72.025 90.66
TPO 76.435 94.47
XO 69.300 87.51