set.seed(123)

datos = data.frame(
gen = gl(3,4,12, c('g1','g2','g3')),
rep = gl(4,1,12, c('r1','r2','r3','r4')),
rto = c(3.5,    3.6,    4.2,
3.8,    3.9,    3.9,
3.6,    4.1,    4.3,
3.5,    3.8,    4.3)
)

datos
##    gen rep rto
## 1   g1  r1 3.5
## 2   g1  r2 3.6
## 3   g1  r3 4.2
## 4   g1  r4 3.8
## 5   g2  r1 3.9
## 6   g2  r2 3.9
## 7   g2  r3 3.6
## 8   g2  r4 4.1
## 9   g3  r1 4.3
## 10  g3  r2 3.5
## 11  g3  r3 3.8
## 12  g3  r4 4.3
boxplot(rto ~ gen, data=datos)

boxplot(rto ~ rep, data=datos)

##TABLA ANALISIS DE VARIANZA 
mod = aov(rto ~ gen, datos)
summary(mod)
##             Df Sum Sq Mean Sq F value Pr(>F)
## gen          2 0.0800 0.04000   0.408  0.677
## Residuals    9 0.8825 0.09806
### EJEMPLO 2

datos = data.frame(
  fert = gl(5,12,60, c('ctrl', 'D1','D2','D3','D4')),
  AF = sort(rnorm(60,10,0.8))
)

boxplot(AF ~ fert, datos)

###TABLA DE ANALISIS DE VARIANZA EJEMPLO 2
mod2 = aov(AF ~ fert,
           datos)
summary(mod2)
##             Df Sum Sq Mean Sq F value Pr(>F)    
## fert         4 28.541   7.135   142.5 <2e-16 ***
## Residuals   55  2.754   0.050                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1