Cargar paquetes y datos

library(readxl)
library(agricolae)
library(ggplot2)

# Cargar base de datos
practica <- read_excel("practica.xlsx")

# Convertir a factores
practica$Genotipo <- as.factor(practica$Genotipo)
practica$Rep <- as.factor(practica$Rep)

Verificación de datos

head(practica)
## # A tibble: 6 × 8
##   Genotipo  Rep    PS20 `AF20 (cm²)` `PS35 (g)` `AF35 (cm²)` `PS50 (g)`
##   <fct>     <fct> <dbl>        <dbl>      <dbl>        <dbl>      <dbl>
## 1 Barbosa   1      3.68         273.       14.9         955.       41.1
## 2 Barbosa   2      3.82         283.       15.3         982.       42.7
## 3 Barbosa   3      3.96         297.       15.6         996.       44.0
## 4 Barbosa   4      3.84         287.       15.7         958.       42.7
## 5 Supervida 1      4.04         286.       16.8        1042.       47.8
## 6 Supervida 2      4.14         290        16.4        1066.       47.8
## # ℹ 1 more variable: `AF50 (cm²)` <dbl>

ANOVA

modelo <- aov(PS20 ~ Genotipo + Rep, data = practica)

summary(modelo)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## Genotipo     9 2.0170 0.22411   33.91 1.94e-12 ***
## Rep          3 0.3332 0.11105   16.80 2.34e-06 ***
## Residuals   27 0.1784 0.00661                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Comparación de medias de Tukey

tukey <- HSD.test(
  modelo,
  "Genotipo",
  group = TRUE,
  console = TRUE
)
## 
## Study: modelo ~ "Genotipo"
## 
## HSD Test for PS20 
## 
## Mean Square Error:  0.006608889 
## 
## Genotipo,  means
## 
##                    PS20        std r         se  Min  Max    Q25   Q50    Q75
## Barbosa          3.8250 0.11474610 4 0.04064754 3.68 3.96 3.7850 3.830 3.8700
## Caribbean gold   4.3300 0.11775681 4 0.04064754 4.17 4.45 4.2900 4.350 4.3900
## CAYUCOS BEACH RZ 4.2325 0.20886599 4 0.04064754 4.01 4.49 4.1000 4.215 4.3475
## Deputy           4.1250 0.09746794 4 0.04064754 3.99 4.21 4.0875 4.150 4.1875
## Lagunero         3.6275 0.07932003 4 0.04064754 3.53 3.71 3.5825 3.635 3.6800
## Primepac         4.2075 0.10874282 4 0.04064754 4.14 4.37 4.1550 4.160 4.2125
## Supervida        4.1500 0.09416298 4 0.04064754 4.04 4.27 4.1150 4.145 4.1800
## UAAAN3           3.7175 0.11324752 4 0.04064754 3.55 3.80 3.7075 3.760 3.7700
## UAAAN5           4.0850 0.15588457 4 0.04064754 3.89 4.25 4.0025 4.100 4.1825
## Ultrajelly       3.9100 0.16206994 4 0.04064754 3.74 4.12 3.8150 3.890 3.9850
## 
## Alpha: 0.05 ; DF Error: 27 
## Critical Value of Studentized Range: 4.864449 
## 
## Minimun Significant Difference: 0.1977278 
## 
## Treatments with the same letter are not significantly different.
## 
##                    PS20 groups
## Caribbean gold   4.3300      a
## CAYUCOS BEACH RZ 4.2325     ab
## Primepac         4.2075     ab
## Supervida        4.1500     ab
## Deputy           4.1250      b
## UAAAN5           4.0850     bc
## Ultrajelly       3.9100     cd
## Barbosa          3.8250     de
## UAAAN3           3.7175     de
## Lagunero         3.6275      e

Media general, mínimo y máximo

media <- mean(practica$PS20, na.rm = TRUE)
minimo <- min(practica$PS20, na.rm = TRUE)
maximo <- max(practica$PS20, na.rm = TRUE)

media
## [1] 4.021
minimo
## [1] 3.53
maximo
## [1] 4.49

Coeficiente de variación

CV <- sqrt(deviance(modelo) / df.residual(modelo)) /
      mean(practica$PS20, na.rm = TRUE) * 100

CV
## [1] 2.021763

Gráfica

graf <- tukey$groups
graf$Genotipo <- rownames(graf)

graf$Genotipo <- factor(
  graf$Genotipo,
  levels = sort(unique(graf$Genotipo))
)

ggplot(graf, aes(x = Genotipo, y = PS20)) +
  geom_col(
    width = 0.5,
    fill = "gray40",
    colour = "black",
    linewidth = 0.3
  ) +
  geom_text(
    aes(label = groups),
    vjust = -0.5,
    size = 4.5
  ) +
  labs(
    x = "",
    y = "PS20 (g)"
  ) +
  theme_classic(base_size = 14) +
  theme(
    axis.text.x = element_text(
      angle = 45,
      hjust = 1
    )
  )