Diseño 1 :FACTORIAL EN ARREGLO COMPLETAMENTE AL AZAR

Diseño 2: FACTORIAL COMPLETO EN BLOQUES

Diseño 3: FACTORIAL COMPLETO EN PARCELAS DIVIDIDAS

Diseño 4: FACTORIAL INCOMPLETO AL AZAR

##TRABAJO Factorial incompleto en bloques y covariables diseño en franjas

##ULTIMO TRABAJO QUIZ DE DISEÑO EN MEDIDAS REPETIDAS DISEÑO LATTICE ANALISIS DE PERFILES DISEÑO DE EFECTOS ALEATORIOS

##Diseño en parcelas divididas REQUIERE POR LO MENOS 2 FACTORES

-ES COMO HACER 2 VECES EL EXPERIMENTO, HAY QUE HACER 2 ALEATORIZACIONES

-ES COMUN EN PROBLEMAS DE RIEGO, FERTILIZACION, DENSIDAD DE SIEMBRA, MAQUINARIA(LABRANZA)

#factor 1: parcela (s1,s2,s3)

#factor 2: fertilizacion (f0,f1,f2)

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
xy = expand.grid(x = seq(6), y = seq(4))
xy = sample_frac(xy)
xy$f1 = gl(4, 6, 24, paste0('V',1:4))
xy$f2 = gl(3, 2, 24, paste0('R',1:3))
xy$rep = gl(2, 1, 24, paste0('r',1:2))
xy$name = paste0(xy$f1, xy$f2, xy$rep)
xy
##    x y f1 f2 rep   name
## 1  6 1 V1 R1  r1 V1R1r1
## 2  4 1 V1 R1  r2 V1R1r2
## 3  4 2 V1 R2  r1 V1R2r1
## 4  6 2 V1 R2  r2 V1R2r2
## 5  5 2 V1 R3  r1 V1R3r1
## 6  4 3 V1 R3  r2 V1R3r2
## 7  4 4 V2 R1  r1 V2R1r1
## 8  6 4 V2 R1  r2 V2R1r2
## 9  2 1 V2 R2  r1 V2R2r1
## 10 1 2 V2 R2  r2 V2R2r2
## 11 6 3 V2 R3  r1 V2R3r1
## 12 2 2 V2 R3  r2 V2R3r2
## 13 2 4 V3 R1  r1 V3R1r1
## 14 5 1 V3 R1  r2 V3R1r2
## 15 3 3 V3 R2  r1 V3R2r1
## 16 3 2 V3 R2  r2 V3R2r2
## 17 3 1 V3 R3  r1 V3R3r1
## 18 5 3 V3 R3  r2 V3R3r2
## 19 1 4 V4 R1  r1 V4R1r1
## 20 1 3 V4 R1  r2 V4R1r2
## 21 1 1 V4 R2  r1 V4R2r1
## 22 2 3 V4 R2  r2 V4R2r2
## 23 5 4 V4 R3  r1 V4R3r1
## 24 3 4 V4 R3  r2 V4R3r2
#COMPLETAMENTE ALETORIZADO

-r: Repeticiones -R: Riego -V: Variedad

library(ggplot2)
ggplot(xy)+
  aes(x,y,label=name, fill=f2)+
  geom_tile(color='white')+
  geom_label(fill='white')

##DIVIDO EN PARCELAS
library(dplyr)
xy = expand.grid(y = seq(4), x = seq(6))
f2 = gl(3, 8, 24, paste0('R',1:3))
lf1 = paste0('V',1:4)
f1 = c(sample(lf1),sample(lf1),
       sample(lf1),sample(lf1),
       sample(lf1),sample(lf1))
rep = rep(rep(paste0('r',1:2), each=4), 3)

data = data.frame(xy, f1, f2, rep)
data$name = with(data, paste0(f1, rep))
library(ggplot2)
ggplot(data)+
  aes(x,y,label=name, fill=f1)+
  geom_tile(color='white')+
  geom_text()+
  facet_wrap(~f2, scales = 'free')+
  theme(axis.text = element_blank())

set.seed(123)
data$biom = rnorm(24)
ggplot(data)+
  aes(f2, biom)+
  geom_boxplot()

ggplot(data)+
  aes(f1, biom)+
  geom_boxplot()

ggplot(data)+
  aes(f2, biom, fill=f1)+
  geom_boxplot()

##PARA HACER EL ANALISIS DE VARIANZA NO SE USA LA AOV
library(lme4)
## Loading required package: Matrix
mod1 = aov(biom ~ f2 * f1 + Error(f2:rep), data)
## Warning in aov(biom ~ f2 * f1 + Error(f2:rep), data): Error() model is singular
summary(mod1)
## 
## Error: f2:rep
##           Df Sum Sq Mean Sq F value Pr(>F)  
## f2         2  3.332  1.6659   8.078  0.062 .
## Residuals  3  0.619  0.2062                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Error: Within
##           Df Sum Sq Mean Sq F value Pr(>F)  
## f1         3  7.890  2.6301   4.223 0.0403 *
## f2:f1      6  3.701  0.6168   0.990 0.4849  
## Residuals  9  5.605  0.6228                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

##Concluciones -No se rechaza la hipotesis de no interaccion entre el riego y las variedades por lo tanto no hay interaccion -El riego no tuvo efecto sobre la biomasa pvalue >5% -la variedad no tuvo efecto sobre la biomasa pvalue >5%