library(readxl)
df <- read_excel("C:/Users/User/Documents/MANEJOS/MANEJO INTEGRADO DE PLAGAS/datos_m.xlsx", 
    sheet = "Datos")
df
## # A tibble: 63 × 5
##    Muestreo   dds Nombre `%ninfas` `#adultos/foliolo`
##       <dbl> <dbl> <chr>      <dbl>              <dbl>
##  1        1    29 CTR            3                 37
##  2        1    29 CTR            1                 12
##  3        1    29 CTR            3                858
##  4        1    29 JP             3                619
##  5        1    29 JP             1                166
##  6        1    29 JP             3                 25
##  7        1    29 CAP            3                454
##  8        1    29 CAP            1                232
##  9        1    29 CAP            3                176
## 10        1    29 BUP            3                794
## # ℹ 53 more rows
library(nortest)
library(moments)
skewness(rnorm(n=df$`#adultos/foliolo`, mean=mean(df$`#adultos/foliolo`), sd=sd(df$`#adultos/foliolo`)))
## [1] -0.1256072
kurtosis(df$`#adultos/foliolo`)
## [1] 7.181306
shapiro.test(df$`#adultos/foliolo`)
## 
##  Shapiro-Wilk normality test
## 
## data:  df$`#adultos/foliolo`
## W = 0.66519, p-value = 1.035e-10
lillie.test(df$`#adultos/foliolo`)
## 
##  Lilliefors (Kolmogorov-Smirnov) normality test
## 
## data:  df$`#adultos/foliolo`
## D = 0.24983, p-value = 1.395e-10
library(agricolae)
## 
## Attaching package: 'agricolae'
## The following objects are masked from 'package:moments':
## 
##     kurtosis, skewness
mod <- aov(`#adultos/foliolo`~Nombre*dds, df)
summary(mod)
##             Df  Sum Sq Mean Sq F value  Pr(>F)   
## Nombre       6  290239   48373   1.056 0.40167   
## dds          1  344603  344603   7.522 0.00849 **
## Nombre:dds   6  230454   38409   0.838 0.54642   
## Residuals   49 2244912   45815                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
comparison<- LSD.test(mod,c("Nombre"),alpha=0.01,group=TRUE)
print(comparison$groups)
##         #adultos/foliolo groups
## BUP            299.44444      a
## JP             162.11111      a
## CAP            149.33333      a
## CAP_BUP        148.44444      a
## JP_CAP         138.55556      a
## CTR            127.66667      a
## JP_BUP          53.77778      a
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
df1 <- filter(df, dds=="29")
mod <- aov(`#adultos/foliolo`~Nombre*dds, df1)
summary(mod)
##             Df  Sum Sq Mean Sq F value Pr(>F)
## Nombre       6  584729   97455    1.18  0.371
## Residuals   14 1156225   82587
comparison<- LSD.test(mod,c("Nombre"),alpha=0.01,group=TRUE)
print(comparison$groups)
##         #adultos/foliolo groups
## BUP            629.00000      a
## CTR            302.33333      a
## CAP            287.33333      a
## JP_CAP         273.00000      a
## JP             270.00000      a
## CAP_BUP        120.33333      a
## JP_BUP          63.33333      a
library(dplyr)
df2 <- filter(df, dds=="45")
mod <- aov(`#adultos/foliolo`~Nombre*dds, df2)
summary(mod)
##             Df Sum Sq Mean Sq F value Pr(>F)
## Nombre       6 165475   27579   0.828  0.567
## Residuals   14 466285   33306
comparison<- LSD.test(mod,c("Nombre"),alpha=0.01,group=TRUE)
print(comparison$groups)
##         #adultos/foliolo groups
## CAP_BUP        287.66667      a
## BUP            118.00000      a
## JP              52.00000      a
## CAP             47.00000      a
## CTR             34.00000      a
## JP_BUP          26.00000      a
## JP_CAP          18.66667      a
library(dplyr)
df3 <- filter(df, dds=="59")
mod <- aov(`#adultos/foliolo`~Nombre*dds, df3)
summary(mod)
##             Df Sum Sq Mean Sq F value Pr(>F)
## Nombre       6  45239    7540   0.511  0.791
## Residuals   14 206737   14767
comparison<- LSD.test(mod,c("Nombre"),alpha=0.01,group=TRUE)
print(comparison$groups)
##         #adultos/foliolo groups
## JP             164.33333      a
## BUP            151.33333      a
## JP_CAP         124.00000      a
## CAP            113.66667      a
## JP_BUP          72.00000      a
## CTR             46.66667      a
## CAP_BUP         37.33333      a
library(ggplot2)
library(dplyr)
library(ggtext)
## Warning: package 'ggtext' was built under R version 4.3.3
text <- c("Aplicación")
p <- df%>%
  group_by(Nombre, dds)%>%
  summarise(media_trt=mean(`#adultos/foliolo`),
            minimo=min(`#adultos/foliolo`),
            maximo=max(`#adultos/foliolo`)) %>% 
  
  ggplot(aes(x=dds, y=media_trt, color=Nombre))+
  geom_line(size=1, linetype=1)+
  geom_point()+
  ggtitle( 'NÚMERO DE ADULTOS DE MOSCA BLANCA (_Trialeurodes vaporariorum_) 
       \nPRESENTES EN UN FOLIOLO EN SIETE TRATAMIENTOS')+
    theme(plot.title = element_markdown())+
  labs(x = 'Días Después de Siembra', 
       y = 'Número de adultos por foliolo',
       color = "TRATAMIENTOS")
## `summarise()` has grouped output by 'Nombre'. You can override using the
## `.groups` argument.
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
p

p+
  geom_vline(size=1, linetype=2, xintercept=37, color="red")+
  annotate("text",
  label = "Aplicación",
  x = 40, y = 610, hjust = 0.5, vjust = 0)

mod <- aov(`%ninfas`~Nombre*dds, df1)
summary(mod)
##             Df Sum Sq Mean Sq F value Pr(>F)
## Nombre       6  1.143  0.1905   0.167  0.982
## Residuals   14 16.000  1.1429
comparison<- LSD.test(mod,c("Nombre"),alpha=0.01,group=TRUE)
print(comparison$groups)
##          %ninfas groups
## JP_CAP  3.000000      a
## BUP     2.333333      a
## CAP     2.333333      a
## CAP_BUP 2.333333      a
## CTR     2.333333      a
## JP      2.333333      a
## JP_BUP  2.333333      a
mod <- aov(`%ninfas`~Nombre*dds, df2)
summary(mod)
##             Df Sum Sq Mean Sq F value Pr(>F)
## Nombre       6  14.48   2.413   0.905  0.519
## Residuals   14  37.33   2.667
comparison<- LSD.test(mod,c("Nombre"),alpha=0.01,group=TRUE)
print(comparison$groups)
##          %ninfas groups
## CAP     3.666667      a
## JP      3.666667      a
## BUP     3.000000      a
## CTR     3.000000      a
## JP_BUP  3.000000      a
## JP_CAP  3.000000      a
## CAP_BUP 1.000000      a
mod <- aov(`%ninfas`~Nombre*dds, df3)
summary(mod)
##             Df Sum Sq Mean Sq F value Pr(>F)
## Nombre       6  23.62   3.937   0.504  0.795
## Residuals   14 109.33   7.810
comparison<- LSD.test(mod,c("Nombre"),alpha=0.01,group=TRUE)
print(comparison$groups)
##          %ninfas groups
## CTR     6.333333      a
## BUP     5.666667      a
## CAP     5.000000      a
## CAP_BUP 4.333333      a
## JP_CAP  4.333333      a
## JP      3.666667      a
## JP_BUP  3.000000      a
mod <- aov(`%ninfas`~Nombre*dds, df)
summary(mod)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## Nombre       6  13.21    2.20   0.590 0.736968    
## dds          1  49.05   49.05  13.139 0.000687 ***
## Nombre:dds   6  12.47    2.08   0.557 0.762352    
## Residuals   49 182.92    3.73                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
comparison<- LSD.test(mod,c("Nombre"),alpha=0.01,group=TRUE)
print(comparison$groups)
##          %ninfas groups
## CTR     3.888889      a
## BUP     3.666667      a
## CAP     3.666667      a
## JP_CAP  3.444444      a
## JP      3.222222      a
## JP_BUP  2.777778      a
## CAP_BUP 2.555556      a
library(nortest)
library(moments)
skewness(rnorm(n=df$`%ninfas`, mean=mean(df$`%ninfas`), sd=sd(df$`%ninfas`)))
## [1] -0.1636103
kurtosis(df$`%ninfas`)
## [1] 0.8061241
shapiro.test(df$`%ninfas`)
## 
##  Shapiro-Wilk normality test
## 
## data:  df$`%ninfas`
## W = 0.8016, p-value = 8.706e-08
lillie.test(df$`%ninfas`)
## 
##  Lilliefors (Kolmogorov-Smirnov) normality test
## 
## data:  df$`%ninfas`
## D = 0.33965, p-value < 2.2e-16
library(ggplot2)
library(dplyr)
library(ggtext)
text <- c("Applicación")
p <- df%>%
  group_by(Nombre, dds)%>%
  summarise(media_trt=mean(`%ninfas`),
            minimo=min(`%ninfas`),
            maximo=max(`%ninfas`)) %>% 
  
  ggplot(aes(x=dds, y=media_trt, color=Nombre))+
  geom_line(size=1, linetype=1)+
  geom_point()+
  ggtitle('GRADO DE PRESENCIA DE NINFAS DE MOSCA BLANCA 
  \n(_Trialeurodes vaporariorum_) 
          \nPRESENTES EN UN FOLIOLO EN SIETE TRATAMIENTOS')+
  theme(plot.title = element_markdown())+
  labs(x = 'Días Después de Siembra', 
       y = 'Grado de presencia de ninfas por foliolo',
       color="TRATAMIENTOS") 
## `summarise()` has grouped output by 'Nombre'. You can override using the
## `.groups` argument.
p

p+
  geom_vline(size=1, linetype=2, xintercept=37, color="red")+
  annotate("text",
  label = "Aplicación",
  x = 34, y = 6, hjust = 0.5, vjust = 0)

 efi <- read_excel("C:/Users/User/Documents/MANEJOS/MANEJO INTEGRADO DE PLAGAS/datos_m.xlsx", 
    sheet = "EFICIENCIAS")
efi
## # A tibble: 12 × 3
##    TRATAMIENTO    METODO           `EFICIENCIA (%)`
##    <chr>          <chr>                       <dbl>
##  1 JABÓN POTÁSICO ABOTT                    8.88e-14
##  2 CAPSIALIL      ABOTT                   -2.22e+ 1
##  3 BUPROFEZIN     ABOTT                    0       
##  4 JP+CAP         ABOTT                    0       
##  5 JP+BUP         ABOTT                    2.22e+ 1
##  6 CAP+BUP        ABOTT                    6.67e+ 1
##  7 JABÓN POTÁSICO HENDERSON-TILTON         1.89e-13
##  8 CAPSIALIL      HENDERSON-TILTON        -2.22e+ 1
##  9 BUPROFEZIN     HENDERSON-TILTON         0       
## 10 JP+CAP         HENDERSON-TILTON        -2.86e+ 1
## 11 JP+BUP         HENDERSON-TILTON         2.22e+ 1
## 12 CAP+BUP        HENDERSON-TILTON         6.67e+ 1
EFICIENCIA <- c(0.00,-22.222, 0.00, 0.00, 22.222, 66.667, 0.00,-22.222,0.00, -28.571, 22.222, 66.667 )
efi$`EFICIENCIA (%)` <- EFICIENCIA
efi$`EFICIENCIA (%)`
##  [1]   0.000 -22.222   0.000   0.000  22.222  66.667   0.000 -22.222   0.000
## [10] -28.571  22.222  66.667
efi
## # A tibble: 12 × 3
##    TRATAMIENTO    METODO           `EFICIENCIA (%)`
##    <chr>          <chr>                       <dbl>
##  1 JABÓN POTÁSICO ABOTT                         0  
##  2 CAPSIALIL      ABOTT                       -22.2
##  3 BUPROFEZIN     ABOTT                         0  
##  4 JP+CAP         ABOTT                         0  
##  5 JP+BUP         ABOTT                        22.2
##  6 CAP+BUP        ABOTT                        66.7
##  7 JABÓN POTÁSICO HENDERSON-TILTON              0  
##  8 CAPSIALIL      HENDERSON-TILTON            -22.2
##  9 BUPROFEZIN     HENDERSON-TILTON              0  
## 10 JP+CAP         HENDERSON-TILTON            -28.6
## 11 JP+BUP         HENDERSON-TILTON             22.2
## 12 CAP+BUP        HENDERSON-TILTON             66.7
library(agricolae)
mod <- aov(`EFICIENCIA (%)`~TRATAMIENTO+METODO, efi)
summary(mod)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## TRATAMIENTO  5  10358    2072   30.45 0.000946 ***
## METODO       1     68      68    1.00 0.363217    
## Residuals    5    340      68                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
comparison<- HSD.test(mod,c("TRATAMIENTO"),group=TRUE)
print(comparison$groups)
##                EFICIENCIA (%) groups
## CAP+BUP               66.6670      a
## JP+BUP                22.2220      b
## BUPROFEZIN             0.0000     bc
## JABÓN POTÁSICO         0.0000     bc
## JP+CAP               -14.2855      c
## CAPSIALIL            -22.2220      c
letra <- c("bc", "a", "c", "bc", "b", "c")

library(ggplot2)
library(dplyr)
p <- efi%>%
  group_by(TRATAMIENTO)%>%
  summarise(media_trt=mean(`EFICIENCIA (%)`),
            minimo=min(`EFICIENCIA (%)`),
            maximo=max(`EFICIENCIA (%)`)) %>% 
  
  ggplot(aes(x=TRATAMIENTO, y=media_trt, fill=TRATAMIENTO))+
  geom_col()+
  geom_text(aes(label=letra),vjust = 1, hjust=1)+
  geom_errorbar(aes(ymin=minimo, ymax=maximo), width=0.2, color='black', 
                position="dodge")+
  labs(title = 'Eficiencia de los tratamientos (Método de Abott)', 
       x = 'Tratamientos', 
       y = 'Eficiencia (%)') +
  theme_minimal()  
p+
  theme(axis.text.x = element_blank(),
        axis.ticks.x = element_blank())+
  xlab("Tratamientos")

EFICIENCIA <- c(0,0,0,0,0,0,0.00,-22.222,0.00, -28.571, 22.222, 66.667 )
TRT <- c("JABON POTÁSICO", "CAPSIALIL","BUPROFEZIN", "JP+CAP", "JP+BUP", "CAP+BUP", "JABON POTÁSICO", "CAPSIALIL","BUPROFEZIN", "JP+CAP", "JP+BUP", "CAP+BUP")
efi_cor <- data.frame(TRT,EFICIENCIA)
efi_cor
##               TRT EFICIENCIA
## 1  JABON POTÁSICO      0.000
## 2       CAPSIALIL      0.000
## 3      BUPROFEZIN      0.000
## 4          JP+CAP      0.000
## 5          JP+BUP      0.000
## 6         CAP+BUP      0.000
## 7  JABON POTÁSICO      0.000
## 8       CAPSIALIL    -22.222
## 9      BUPROFEZIN      0.000
## 10         JP+CAP    -28.571
## 11         JP+BUP     22.222
## 12        CAP+BUP     66.667
library(agricolae)
mod <- aov(EFICIENCIA~TRT, efi_cor)
summary(mod)
##             Df Sum Sq Mean Sq F value Pr(>F)
## TRT          5   3003   600.7   1.154  0.426
## Residuals    6   3124   520.7
comparison<- HSD.test(mod,c("TRT"),group=TRUE)
print(comparison$groups)
##                EFICIENCIA groups
## CAP+BUP           33.3335      a
## JP+BUP            11.1110      a
## BUPROFEZIN         0.0000      a
## JABON POTÁSICO     0.0000      a
## CAPSIALIL        -11.1110      a
## JP+CAP           -14.2855      a
letra <- c("a", "a", "a", "a", "a", "a")

library(ggplot2)
library(dplyr)
p <- efi_cor%>%
  group_by(TRT)%>%
  summarise(media_trt=mean(EFICIENCIA),
            minimo=min(EFICIENCIA),
            maximo=max(EFICIENCIA)) %>% 
  
  ggplot(aes(x=TRT, y=media_trt, fill=TRT))+
  geom_col()+
  geom_text(aes(label=letra),vjust = 1, hjust=1)+
  geom_errorbar(aes(ymin=minimo, ymax=maximo), width=0.2, color='black', 
                position="dodge")+
  labs(title = 'Eficiencia de los tratamientos (Método de Henderson-Tilton)', 
       x = 'Tratamientos', 
       y = 'Eficiencia (%)') +
  theme_minimal()  
p+
  theme(axis.text.x = element_blank(),
        axis.ticks.x = element_blank())+
  xlab("Tratamientos")