Índice de cosecha es un rasgo clave para detectar genotipos de papa tolerante a la sequía

Authors
Affiliation

Franklin Santos

Universidad Austral de Chile

Benjamín Ignacio Díaz Huarnez

Universidad Austral de Chile

Willi Heitmann

Universidad Austral de Chile

Parcelas Divididas

library(tidyverse)
library(metan)
library(readxl)
library(agricolae)
potato2 <- read_excel("/Users/franklin/Documents/R/Expdesig_uach/cap_3/Final_task/potato2.xlsx")

potato2 <- as_factor(potato2, 1:4)
head(potato2)
# A tibble: 6 × 9
  GENOTYPE TREAT BLOCK geno      BIOMDW    HI   WUE  TWUE   TDW
  <fct>    <fct> <fct> <fct>      <dbl> <dbl> <dbl> <dbl> <dbl>
1 G01      WW    I     CIP720088   17.8 0.719  7.48  5.38  12.8
2 G01      WD    I     CIP720088   18.6 0.625  8.48  5.30  11.6
3 G01      WD    II    CIP720088   29.2 0.677 11.6   7.84  19.8
4 G01      WW    II    CIP720088   16.5 0.717  8.38  6.01  11.8
5 G01      WW    III   CIP720088   52.5 0.812  9.00  7.31  42.7
6 G01      WW    IV    CIP720088   46.6 0.758 10.7   8.08  35.4
## Analisis descriptivo
potato2%>%
  select(-1,-2,-3,-4)%>%
  desc_stat(stats = c("mean, se, kurt, skew, cv, min, max"))%>%
  round_cols()
# A tibble: 5 × 8
  variable  mean    se  kurt  skew    cv   min    max
  <chr>    <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>  <dbl>
1 BIOMDW   62.3   1.92  0.03  0.5   37.7 14.4  133.  
2 HI        0.5   0.01  0.07 -0.5   30.4  0.05   0.81
3 TDW      31.6   1.41  0.5   0.92  54.4  2.37  86.2 
4 TWUE      5.19  0.15 -0.41  0.01  36.0  0.54   9.26
5 WUE      10.3   0.17 21.9   2.74  20.2  5.11  26.2 

Biomasa total

## Biomasa
av_potato2<-aov(BIOMDW ~  TREAT +
               Error(BLOCK/TREAT)+
               GENOTYPE+
               TREAT:GENOTYPE,
             data=potato2)
summary(av_potato2)

Error: BLOCK
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals  4   3435   858.7               

Error: BLOCK:TREAT
          Df Sum Sq Mean Sq F value   Pr(>F)    
TREAT      1  20737   20737   83.62 0.000794 ***
Residuals  4    992     248                     
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Error: Within
                Df Sum Sq Mean Sq F value Pr(>F)    
GENOTYPE        14  33364  2383.2  13.318 <2e-16 ***
TREAT:GENOTYPE  14   3535   252.5   1.411   0.16    
Residuals      112  20042   178.9                   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Hay diferencia significaiva para BIOMDW entre los tipos de riego a un valor p=0.000794 ***. 
#De igual manera hay diferencias en al menos un tipo de genotipo.Y no hay interacción

Tukey_R<-HSD.test(potato2$BIOMDW, potato2$TREAT,
                  alpha=0.01, 
                  DFerror = 4, 
                  MSerror = 248);Tukey_R 
$statistics
  MSerror Df     Mean       CV      MSD
      248  4 62.33287 25.26439 11.84043

$parameters
   test        name.t ntr StudentizedRange alpha
  Tukey potato2$TREAT   2         6.511369  0.01

$means
   potato2$BIOMDW      std  r       se   Min    Max    Q25   Q50   Q75
WD       50.57507 15.81736 75 1.818424 14.40 114.54 42.005 49.41 58.26
WW       74.09067 24.06450 75 1.818424 16.47 132.70 58.630 71.93 92.99

$comparison
NULL

$groups
   potato2$BIOMDW groups
WW       74.09067      a
WD       50.57507      b

attr(,"class")
[1] "group"
Tukey_R<-HSD.test(potato2$BIOMDW, potato2$GENOTYPE,
                  alpha=0.01, 
                  DFerror = 112, 
                  MSerror = 178.9);Tukey_R 
$statistics
  MSerror  Df     Mean       CV      MSD
    178.9 112 62.33287 21.45794 23.79519

$parameters
   test           name.t ntr StudentizedRange alpha
  Tukey potato2$GENOTYPE  15         5.625795  0.01

$means
    potato2$BIOMDW      std  r       se   Min    Max     Q25    Q50      Q75
G01         26.419 13.19852 10 4.229657 14.40  52.54 17.8950 20.285  29.0250
G02         62.096 16.71501 10 4.229657 48.33  98.62 50.4525 56.535  69.5500
G03         66.056 19.63224 10 4.229657 36.62  95.44 58.4300 64.705  79.2800
G04         62.283 15.61178 10 4.229657 38.59  84.39 52.6000 59.470  74.0475
G05         57.218 13.24235 10 4.229657 36.48  76.64 47.6325 54.915  68.8950
G06         77.112 24.59657 10 4.229657 46.69 114.54 58.6250 67.735  97.2300
G07         87.800 23.34438 10 4.229657 52.95 132.70 73.9800 80.410  97.9100
G08         49.388 13.35952 10 4.229657 35.15  82.12 42.2875 45.145  53.1575
G09         67.964 23.99653 10 4.229657 30.29 104.54 50.9200 65.415  83.0875
G10         52.631 15.66387 10 4.229657 22.32  73.35 43.8850 53.370  63.5950
G11         59.123 19.33491 10 4.229657 41.77 103.48 44.7275 53.670  65.1500
G12         44.478 13.00438 10 4.229657 30.30  60.74 33.9000 39.440  58.7950
G13         72.917 27.41983 10 4.229657 44.23 118.51 53.6575 56.915  99.0575
G14         67.809 16.90388 10 4.229657 47.41 102.92 56.3700 63.200  77.0950
G15         81.699 20.67044 10 4.229657 53.20 109.58 67.1150 75.585 100.5125

$comparison
NULL

$groups
    potato2$BIOMDW groups
G07         87.800      a
G15         81.699     ab
G06         77.112    abc
G13         72.917   abcd
G09         67.964  abcde
G14         67.809  abcde
G03         66.056  abcde
G04         62.283   bcde
G02         62.096   bcde
G11         59.123   bcde
G05         57.218    cde
G10         52.631     de
G08         49.388    def
G12         44.478     ef
G01         26.419      f

attr(,"class")
[1] "group"
#SHAPIRO-NORMALIDAD, LEVEN-HOMOGENEIDAD, DURBIN WATSON-INDEPENDENCIA
resid_potato2 <- aov(BIOMDW ~  TREAT*GENOTYPE+BLOCK/TREAT,
                     data=potato2)
plot(resid_potato2, 2)

plot(resid_potato2, 1)

plot(resid_potato2, 3)

plot(resid_potato2, 4)

Indice de cosecha

## Indice de cosecha
av_HI<-aov(HI ~ TREAT +
                  Error(BLOCK/TREAT)+
                  GENOTYPE+
                  TREAT:GENOTYPE,
                data=potato2)
summary(av_HI)

Error: BLOCK
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals  4 0.1002 0.02504               

Error: BLOCK:TREAT
          Df  Sum Sq Mean Sq F value Pr(>F)   
TREAT      1 0.12138 0.12138   22.81 0.0088 **
Residuals  4 0.02128 0.00532                  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Error: Within
                Df Sum Sq Mean Sq F value Pr(>F)    
GENOTYPE        14 2.6929 0.19235  60.963 <2e-16 ***
TREAT:GENOTYPE  14 0.0748 0.00534   1.693 0.0667 .  
Residuals      112 0.3534 0.00316                   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(emmeans)
Welcome to emmeans.
Caution: You lose important information if you filter this package's results.
See '? untidy'
library(multcompView)
library(inti)
Loading required package: shiny
##grafica de interaccion
#calcular las EMMs para treat |Genotipo
mc <- emmeans(av_HI, ~TREAT|GENOTYPE) %>% 
  multcomp::cld(Letters = letters, reversed = TRUE) %>% 
  mutate(across(.group, trimws))
Note: re-fitting model with sum-to-zero contrasts
# Calcular las EMMs para gnt | treat
mcHI <- emmeans(av_HI, ~ GENOTYPE|TREAT) %>% 
  multcomp::cld(Letters = letters, reversed = TRUE) %>% 
  mutate(across(.group, trimws)) %>% 
  mutate(across(emmean, ~round(., 2))) %>% 
  unite(HI, c(emmean, .group), sep = " ") %>% 
  dplyr::select(1:3)
Note: re-fitting model with sum-to-zero contrasts
# Graficar los resultados
hi <- mc %>% 
  plot_smr(type = "line",
           color = TRUE,
           x = "GENOTYPE",
           xlab = "Genotipos",
           y = "emmean",
           ylab = "Índice de cosecha",
           group = "TREAT",
           glab = "Riego",
           legend = "right",
           ylimits = c(0, 1, 0.2),
           error = "SE",
           sig = ".group")

hi

#AMBOS FACTORES TIENEN DIF SIGNIFICATIVA Y HAY INTERACCIÓN
resid_HI <- aov(HI ~  TREAT*GENOTYPE+BLOCK/TREAT,
                     data=potato2)
plot(resid_HI, 2)

plot(resid_HI, 1)

plot(resid_HI, 3)

plot(resid_HI, 4)

Peso seco de tubérculos

av_TDW<-aov(TDW ~  TREAT +
                  Error(BLOCK/TREAT)+
                  GENOTYPE+
                  TREAT:GENOTYPE,
                data=potato2)
summary(av_TDW)

Error: BLOCK
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals  4   1756   438.9               

Error: BLOCK:TREAT
          Df Sum Sq Mean Sq F value  Pr(>F)   
TREAT      1   9112    9112   41.09 0.00304 **
Residuals  4    887     222                   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Error: Within
                Df Sum Sq Mean Sq F value Pr(>F)    
GENOTYPE        14  20795  1485.4  17.691 <2e-16 ***
TREAT:GENOTYPE  14   2190   156.5   1.864 0.0379 *  
Residuals      112   9404    84.0                   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mc_tdw <- emmeans(av_TDW, ~TREAT|GENOTYPE) %>% 
  multcomp::cld(Letters = letters, reversed = TRUE) %>% 
  mutate(across(.group, trimws))
Note: re-fitting model with sum-to-zero contrasts
# Calcular las EMMs para gnt | treat
tdw_mc <- emmeans(av_TDW, ~ GENOTYPE|TREAT) %>% 
  multcomp::cld(Letters = letters, reversed = TRUE) %>% 
  mutate(across(.group, trimws)) %>% 
  mutate(across(emmean, ~round(., 2))) %>% 
  unite(TDW, c(emmean, .group), sep = " ") %>% 
  dplyr::select(1:3)
Note: re-fitting model with sum-to-zero contrasts
# Graficar los resultados
tdw <- mc_tdw %>% 
  plot_smr(type = "line",
           color = TRUE,
           x = "GENOTYPE",
           xlab = "Genotipos",
           y = "emmean",
           ylab = "Peso seco de tubérculos",
           group = "TREAT",
           glab = "Riego",
           legend = 'right',
           ylimits = c(0, 75, 10),
           error = "SE",
           sig = ".group")

tdw

#supuestos: NORMALIDAD, HOMOGENEIDAD, INDEPENDENCIA 
resid_tdw <- aov(TDW ~  TREAT*GENOTYPE+BLOCK/TREAT,
                     data=potato2)
plot(resid_tdw, 2)

plot(resid_tdw, 1)

plot(resid_tdw, 3)

plot(resid_tdw, 4)

Uso eficiente de agua

##WUE
av_potato2<-aov(WUE ~  TREAT +
                  Error(BLOCK/TREAT)+
                  GENOTYPE+
                  TREAT:GENOTYPE,
                data=potato2)
summary(av_potato2)

Error: BLOCK
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals  4  11.64   2.909               

Error: BLOCK:TREAT
          Df Sum Sq Mean Sq F value   Pr(>F)    
TREAT      1 124.78  124.78   118.2 0.000406 ***
Residuals  4   4.22    1.06                     
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Error: Within
                Df Sum Sq Mean Sq F value   Pr(>F)    
GENOTYPE        14  140.5  10.034   3.433 0.000121 ***
TREAT:GENOTYPE  14   40.4   2.889   0.988 0.469906    
Residuals      112  327.4   2.923                     
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Hay diferencia significaiva para WUE entre los tipos de riego a un valor p=0.000406 ***. 
#De igual manera hay diferencias en al menos un tipo de genotipo.Y no hay interacción

Tukey_R<-HSD.test(potato2$WUE, potato2$TREAT,
                  alpha=0.01, 
                  DFerror = 4, 
                  MSerror = 1.06);Tukey_R 
$statistics
  MSerror Df     Mean       CV       MSD
     1.06  4 10.32749 9.969149 0.7740956

$parameters
   test        name.t ntr StudentizedRange alpha
  Tukey potato2$TREAT   2         6.511369  0.01

$means
   potato2$WUE      std  r        se      Min      Max       Q25       Q50
WD   11.239565 2.241295 75 0.1188837 5.524348 26.23454 10.259518 10.918783
WW    9.415418 1.435103 75 0.1188837 5.109102 12.13940  8.578011  9.269235
        Q75
WD 12.00450
WW 10.36722

$comparison
NULL

$groups
   potato2$WUE groups
WD   11.239565      a
WW    9.415418      b

attr(,"class")
[1] "group"
Tukey_R<-HSD.test(potato2$WUE, potato2$GENOTYPE,
                  alpha=0.01, 
                  DFerror = 112, 
                  MSerror = 2.923);Tukey_R
$statistics
  MSerror  Df     Mean       CV      MSD
    2.923 112 10.32749 16.55463 3.041574

$parameters
   test           name.t ntr StudentizedRange alpha
  Tukey potato2$GENOTYPE  15         5.625795  0.01

$means
    potato2$WUE       std  r        se       Min      Max       Q25       Q50
G01    9.497248 1.5051960 10 0.5406478  7.484224 11.82728  8.406023  9.351581
G02   11.803335 1.3197541 10 0.5406478  9.587523 13.32864 10.658534 12.364674
G03   12.124126 1.2739400 10 0.5406478  8.838542 13.13439 11.937530 12.205761
G04    9.969693 1.0101993 10 0.5406478  8.619286 11.50922  9.042423 10.089898
G05    8.770404 1.7665172 10 0.5406478  5.156436 11.43886  8.226592  8.495613
G06   11.394258 5.2923656 10 0.5406478  8.333333 26.23454  9.264110  9.740685
G07   10.687591 1.2245267 10 0.5406478  8.536735 12.57035 10.365465 10.807497
G08   10.195353 1.7740914 10 0.5406478  7.848592 13.62103  8.780442 10.271556
G09    9.154449 1.4981764 10 0.5406478  5.524348 11.34875  8.820321  9.378910
G10    9.551463 1.0887104 10 0.5406478  8.291883 11.99726  8.871328  9.426845
G11   10.138029 1.0234221 10 0.5406478  8.821308 12.16536  9.497306 10.033812
G12    9.603283 0.9908093 10 0.5406478  8.368383 10.71783  8.677072  9.543401
G13   10.554022 1.1278071 10 0.5406478  8.454769 12.57606 10.032161 10.393748
G14    9.961913 2.6265411 10 0.5406478  5.109102 13.10060  9.219832 10.716782
G15   11.507204 0.6601548 10 0.5406478 10.425101 12.27110 10.976290 11.810951
          Q75
G01 10.474727
G02 12.754845
G03 13.041211
G04 10.678152
G05  9.731079
G06 10.815506
G07 11.258460
G08 10.946516
G09  9.686493
G10  9.965319
G11 10.804560
G12 10.633946
G13 11.233476
G14 11.829203
G15 11.989085

$comparison
NULL

$groups
    potato2$WUE groups
G03   12.124126      a
G02   11.803335     ab
G15   11.507204     ab
G06   11.394258     ab
G07   10.687591     ab
G13   10.554022     ab
G08   10.195353     ab
G11   10.138029     ab
G04    9.969693     ab
G14    9.961913     ab
G12    9.603283     ab
G10    9.551463     ab
G01    9.497248     ab
G09    9.154449     ab
G05    8.770404      b

attr(,"class")
[1] "group"
resid_potato2 <- aov(WUE ~  TREAT*GENOTYPE+BLOCK/TREAT,
                     data=potato2)
plot(resid_potato2, 2)

plot(resid_potato2, 1)

plot(resid_potato2, 3)

plot(resid_potato2, 4)

Eficiencia uso de agua de tubérculos

##TWUE
av_TWUE<-aov(TWUE ~  TREAT +
                  Error(BLOCK/TREAT)+
                  GENOTYPE+
                  TREAT:GENOTYPE,
                data=potato2)
summary(av_TWUE)

Error: BLOCK
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals  4  25.47   6.368               

Error: BLOCK:TREAT
          Df Sum Sq Mean Sq F value Pr(>F)
TREAT      1  1.360   1.360   1.247  0.327
Residuals  4  4.363   1.091               

Error: Within
                Df Sum Sq Mean Sq F value Pr(>F)    
GENOTYPE        14  395.3  28.235  39.540 <2e-16 ***
TREAT:GENOTYPE  14   14.2   1.013   1.419  0.156    
Residuals      112   80.0   0.714                   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Hay diferencia significaiva para TWUE en al menos un tipo de genotipo a un valor p=<2e-16 ***. 

#FIJARSE EN DE DONDE SE LLAMA 
Tukey_R<-HSD.test(potato2$TWUE, potato2$GENOTYPE,
                  alpha=0.001, 
                  DFerror = 108, 
                  MSerror = 0.635);Tukey_R 
$statistics
  MSerror  Df     Mean       CV      MSD
    0.635 108 5.190354 15.35288 1.644565

$parameters
   test           name.t ntr StudentizedRange alpha
  Tukey potato2$GENOTYPE  15         6.526256 0.001

$means
    potato2$TWUE       std  r        se       Min      Max      Q25      Q50
G01     6.678330 1.2687163 10 0.2519921 5.1903543 8.560701 5.503319 6.627057
G02     7.188334 0.9703182 10 0.2519921 5.1014147 8.357964 6.852823 7.167239
G03     7.952176 1.0067269 10 0.2519921 5.6959014 9.261978 7.844924 8.142050
G04     4.462508 0.4395758 10 0.2519921 3.5144020 5.150054 4.346784 4.466822
G05     3.393723 0.8466475 10 0.2519921 2.3829097 5.190354 2.885321 3.126527
G06     5.312406 0.6966550 10 0.2519921 4.2617450 6.267642 4.782849 5.446657
G07     5.955517 1.0758974 10 0.2519921 4.4833476 7.642416 5.168010 5.772458
G08     5.842759 1.4499485 10 0.2519921 3.4225352 9.056873 5.015951 6.036097
G09     4.432770 0.6622746 10 0.2519921 3.6703273 5.418728 3.790575 4.422071
G10     3.540048 0.9774995 10 0.2519921 1.6707921 5.178082 3.176219 3.573489
G11     1.811246 0.9480197 10 0.2519921 0.5430797 3.441961 1.246672 1.580404
G12     4.142762 0.5892980 10 0.2519921 3.1834663 4.994347 3.660358 4.235201
G13     5.469692 1.0800384 10 0.2519921 3.3350933 7.393228 5.013145 5.466829
G14     4.389949 1.0936678 10 0.2519921 2.2966326 6.090543 3.988985 4.290157
G15     7.283095 0.8401103 10 0.2519921 5.3691578 8.108766 6.854163 7.476366
         Q75
G01 7.705470
G02 7.838901
G03 8.334220
G04 4.722193
G05 3.564221
G06 5.867169
G07 6.863330
G08 6.198121
G09 5.028707
G10 4.009862
G11 2.036029
G12 4.585472
G13 6.076044
G14 5.040969
G15 7.920631

$comparison
NULL

$groups
    potato2$TWUE groups
G03     7.952176      a
G15     7.283095     ab
G02     7.188334     ab
G01     6.678330    abc
G07     5.955517    bcd
G08     5.842759    bcd
G13     5.469692    cde
G06     5.312406    cde
G04     4.462508    def
G09     4.432770    def
G14     4.389949    def
G12     4.142762     ef
G10     3.540048      f
G05     3.393723     fg
G11     1.811246      g

attr(,"class")
[1] "group"
# Extraer los datos del objeto Tukey_R
results <- Tukey_R$groups

# Convertir los resultados a un data frame
results_df <- as.data.frame(results)
results_df$Genotype <- rownames(results_df)
colnames(results_df) <- c("TWUE", "Group", "Genotype")

# Ordenar el data frame por TWUE
results_df <- results_df[order(results_df$TWUE, decreasing = TRUE),]
results_df$Genotype <- factor(results_df$Genotype, levels = results_df$Genotype)

# Crear el gráfico de barras con ggplot2
ggplot(results_df, aes(x = Genotype, y = TWUE, fill = Group)) +
  geom_bar(stat = "identity") +
  geom_text(aes(label = Group), vjust = -0.5, color = "black") +
  scale_fill_brewer(palette = "Set3") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 1),
        text = element_text(size = 12),
        legend.position = "none") +
  labs(x = "Genotipos", y = "TWUE") +
  ylim(0, max(results_df$TWUE) + 1)

#supuestos: NORMALIDAD, HOMOGENEIDAD, INDEPENDENCIA 
resid_potato2 <- aov(TWUE ~  TREAT*GENOTYPE+BLOCK/TREAT,
                     data=potato2)
plot(resid_potato2, 2)

plot(resid_potato2, 1)

plot(resid_potato2, 3)

plot(resid_potato2, 4)

Análisis de potencia

Biomasa total

# Datos
D1B <- c(18.62, 29.25, 28.35, 14.4, 21.95)
D2B <- c(50.19, 56.82, 48.59, 51.24, 48.33)
D3B <- c(65.39, 36.62, 59.42, 64.02, 38.09)
D4B <- c(38.59, 51.78, 69.27, 60.99, 45.57)
D5B <- c(55.85, 47.64, 36.48, 46.15, 53.98)
D6B <- c(56.33, 46.69, 52.77, 114.54, 65.51)
D7B <- c(52.95, 73.65, 74.97, 77.51, 73.26)
D8B <- c(42.24, 40.51, 54.99, 42.43, 47.66)
D9B <- c(55.45, 61.43, 45.66, 49.41, 30.29)
D10B <- c(22.32, 40.54, 47.22, 44.17, 43.79)
D11B <- c(44.58, 47.49, 41.77, 43.96, 45.17)
D12B <- c(30.93, 30.3, 41.06, 37.82, 33.66)
D13B <- c(56.05, 57.16, 56.67, 52.86, 44.23)
D14B <- c(52.25, 72.01, 55.57, 61.29, 65.11)
D15B <- c(75.58, 53.2, 59.36, 65.59, 75.59)
W1B <- c(17.79, 16.47, 52.54, 46.61, 18.21)
W2B <- c(56.25, 80.16, 57.04, 98.62, 73.72)
W3B <- c(71.93, 58.1, 95.44, 81.73, 89.82)
W4B <- c(55.06, 75.64, 83.59, 84.39, 57.95)
W5B <- c(66.15, 69.81, 71.85, 76.64, 47.63)
W6B <- c(68.4, 110.49, 99.8, 89.52, 67.07)
W7B <- c(83.31, 116.09, 99.04, 132.7, 94.52)
W8B <- c(44.58, 45.71, 82.12, 35.15, 58.49)
W9B <- c(84.02, 69.4, 99.15, 80.29, 104.54)
W10B <- c(62.98, 59.52, 73.35, 68.62, 63.8)
W11B <- c(65.41, 59.85, 75.15, 103.48, 64.37)
W12B <- c(34.62, 59.83, 56.14, 59.68, 60.74)
W13B <- c(48.04, 91.46, 118.51, 101.59, 102.6)
W14B <- c(78.79, 83.97, 47.41, 102.92, 58.77)
W15B <- c(101.9, 109.58, 108.15, 71.69, 96.35)
library(pwr)
# Crear dataframe
datos <- data.frame(
  valor = c(D1B, D2B, D3B, D4B, D5B, D6B, D7B, D8B, D9B, D10B, D11B, D12B, D13B, D14B, D15B,
            W1B, W2B, W3B, W4B, W5B, W6B, W7B, W8B, W9B, W10B, W11B, W12B, W13B, W14B, W15B),
  grupo = factor(rep(1:30, each = 5))
)

# Realizar ANOVA
anova_result <- aov(valor ~ grupo, data = datos)
summary(anova_result)
             Df Sum Sq Mean Sq F value Pr(>F)    
grupo        29  57636  1987.4   9.747 <2e-16 ***
Residuals   120  24468   203.9                   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Calcular eta squared
eta_squared <- function(aov_obj) {
  ss_total <- sum(aov_obj[[1]][, "Sum Sq"])
  ss_between <- aov_obj[[1]][, "Sum Sq"][1]
  eta_sq <- ss_between / ss_total
  return(eta_sq)
}

eta_sq <- eta_squared(summary(anova_result))
print(paste("Eta squared:", eta_sq))
[1] "Eta squared: 0.70198444727548"
# Calcular el tamaño del efecto f
f_value <- sqrt(eta_sq / (1 - eta_sq))
print(paste("Tamaño del efecto f:", f_value))
[1] "Tamaño del efecto f: 1.5347734594139"
pwr.t.test(d=1.2575534692127, sig.level = .05, power= 0.42 , type = "two.sample",alternative = "two.sided")

     Two-sample t test power calculation 

              n = 5.032242
              d = 1.257553
      sig.level = 0.05
          power = 0.42
    alternative = two.sided

NOTE: n is number in *each* group

Peso seco de tubérculos

# Crear dataframe
datos <- data.frame(
  valor = c(w1TD, w2TD, w3TD, w4TD, w5TD, w6TD, w7TD, w8TD, w9TD, w10TD, w11TD, w12TD, w13TD, w14TD, w15TD,
            D1TD, D2TD, D3TD, D4TD, D5TD, D6TD, D7TD, D8TD, D9TD, D10TD, D11TD, D12TD, D13TD, D14TD, D15TD),
  grupo = factor(rep(1:30, each = 5))
)

# Realizar ANOVA
anova_result <- aov(valor ~ grupo, data = datos)
summary(anova_result)
             Df Sum Sq Mean Sq F value Pr(>F)    
grupo        29  32097  1106.8   11.03 <2e-16 ***
Residuals   120  12046   100.4                   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Calcular eta squared
eta_squared <- function(aov_obj) {
  ss_total <- sum(aov_obj[[1]][, "Sum Sq"])
  ss_between <- aov_obj[[1]][, "Sum Sq"][1]
  eta_sq <- ss_between / ss_total
  return(eta_sq)
}

eta_sq <- eta_squared(summary(anova_result))
print(paste("Eta squared:", eta_sq))
[1] "Eta squared: 0.727114787148295"
# Calcular el tamaño del efecto f
f_value <- sqrt(eta_sq / (1 - eta_sq))
print(paste("Tamaño del efecto f:", f_value))
[1] "Tamaño del efecto f: 1.63234324773519"
pwr.t.test(d=1.63234324773519, sig.level = .05, power= 0.80 , type = "two.sample",alternative = "two.sided")

     Two-sample t test power calculation 

              n = 6.995567
              d = 1.632343
      sig.level = 0.05
          power = 0.8
    alternative = two.sided

NOTE: n is number in *each* group

Indice de cosecha

# Crear dataframe
datos <- data.frame(
  valor = c(D1H, D2H, D3H, D4H, D5H, D6H, D7H, D8H, D9H, D10H, D11H, D12H, D13H, D14H, D15H,
            W1H, W2H, W3H, W4H, W5H, W6H, W7H, W8H, W9H, W10H, W11H, W12H, W13H, W14H, W15H),
  grupo = factor(rep(1:30, each = 5))
)

# Realizar ANOVA
anova_result <- aov(valor ~ grupo, data = datos)
summary(anova_result)
             Df Sum Sq Mean Sq F value Pr(>F)    
grupo        29 2.9057 0.10020    25.6 <2e-16 ***
Residuals   120 0.4697 0.00391                   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Calcular eta squared
eta_squared <- function(aov_obj) {
  ss_total <- sum(aov_obj[[1]][, "Sum Sq"])
  ss_between <- aov_obj[[1]][, "Sum Sq"][1]
  eta_sq <- ss_between / ss_total
  return(eta_sq)
}

eta_sq <- eta_squared(summary(anova_result))
print(paste("Eta squared:", eta_sq))
[1] "Eta squared: 0.86084969096433"
# Calcular el tamaño del efecto f
f_value <- sqrt(eta_sq / (1 - eta_sq))
print(paste("Tamaño del efecto f:", f_value))
[1] "Tamaño del efecto f: 2.48726223780722"
pwr.t.test(d=2.48726223780722, sig.level = .05, power= 0.93 , type = "two.sample",alternative = "two.sided")

     Two-sample t test power calculation 

              n = 5.011613
              d = 2.487262
      sig.level = 0.05
          power = 0.93
    alternative = two.sided

NOTE: n is number in *each* group

Uso eficiente de agua

# Crear dataframe
datos <- data.frame(
  valor = c(D1W, D2W, D3W, D4W, D5W, D6W, D7W, D8W, D9W, D10W, D11W, D12W, D13W, D14W, D15W,
            W1W, W2W, W3W, W4W, W5W, W6W, W7W, W8W, W9W, W10W, W11W, W12W, W13W, W14W, W15W),
  grupo = factor(rep(1:30, each = 5))
)

# Realizar ANOVA
anova_result <- aov(valor ~ grupo, data = datos)
summary(anova_result)
             Df Sum Sq Mean Sq F value   Pr(>F)    
grupo        29  305.7   10.54   3.686 2.57e-07 ***
Residuals   120  343.2    2.86                     
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Calcular eta squared
eta_squared <- function(aov_obj) {
  ss_total <- sum(aov_obj[[1]][, "Sum Sq"])
  ss_between <- aov_obj[[1]][, "Sum Sq"][1]
  eta_sq <- ss_between / ss_total
  return(eta_sq)
}

eta_sq <- eta_squared(summary(anova_result))
print(paste("Eta squared:", eta_sq))
[1] "Eta squared: 0.471104806705283"
# Calcular el tamaño del efecto f
f_value <- sqrt(eta_sq / (1 - eta_sq))
print(paste("Tamaño del efecto f:", f_value))
[1] "Tamaño del efecto f: 0.943786927645647"
pwr.t.test(d=0.943786927645647, sig.level = .05, power= 0.265 , type = "two.sample",alternative = "two.sided")

     Two-sample t test power calculation 

              n = 5.079677
              d = 0.9437869
      sig.level = 0.05
          power = 0.265
    alternative = two.sided

NOTE: n is number in *each* group

Uso eficiente de agua del tubérculo

# Crear dataframe
datos <- data.frame(
  valor = c(w1TD, w2TD, w3TD, w4TD, w5TD, w6TD, w7TD, w8TD, w9TD, w10TD, w11TD, w12TD, w13TD, w14TD, w15TD,
            D1TD, D2TD, D3TD, D4TD, D5TD, D6TD, D7TD, D8TD, D9TD, D10TD, D11TD, D12TD, D13TD, D14TD, D15TD),
  grupo = factor(rep(1:30, each = 5))
)

# Realizar ANOVA
anova_result <- aov(valor ~ grupo, data = datos)
summary(anova_result)
             Df Sum Sq Mean Sq F value Pr(>F)    
grupo        29  32097  1106.8   11.03 <2e-16 ***
Residuals   120  12046   100.4                   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Calcular eta squared
eta_squared <- function(aov_obj) {
  ss_total <- sum(aov_obj[[1]][, "Sum Sq"])
  ss_between <- aov_obj[[1]][, "Sum Sq"][1]
  eta_sq <- ss_between / ss_total
  return(eta_sq)
}

eta_sq <- eta_squared(summary(anova_result))
print(paste("Eta squared:", eta_sq))
[1] "Eta squared: 0.727114787148295"
# Calcular el tamaño del efecto f
f_value <- sqrt(eta_sq / (1 - eta_sq))
print(paste("Tamaño del efecto f:", f_value))
[1] "Tamaño del efecto f: 1.63234324773519"
pwr.t.test(d=1.63234324773519, sig.level = .05, power= 0.63 , type = "two.sample",alternative = "two.sided")

     Two-sample t test power calculation 

              n = 5.087052
              d = 1.632343
      sig.level = 0.05
          power = 0.63
    alternative = two.sided

NOTE: n is number in *each* group
pwr.t.test(d=1.63234324773519, sig.level = .05, power= 0.8 , type = "two.sample",alternative = "two.sided")

     Two-sample t test power calculation 

              n = 6.995567
              d = 1.632343
      sig.level = 0.05
          power = 0.8
    alternative = two.sided

NOTE: n is number in *each* group