library(readxl)
muestreo_1<- read_excel("~/MANEJOS/MANEJO INTEGRADO DE ENFERMEDADES/PROYECTO GRUPAL/TABLA CAMPO-PDE-DUOPROTEKT-ROSA-L1.xlsx", sheet ="EVA PREVIA")
muestreo_1
## # A tibble: 40 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      1     0           0             0                 0
##  2      1     0           0             0                 0
##  3      1     0           0             0                 0
##  4      1     0           0.01          0.12              1
##  5      1     0           0             0                 0
##  6      1     0           0             0                 0
##  7      1     0           0             0                 0
##  8      1     0           0.01          0.12              1
##  9      1     0           0             0                 0
## 10      1     0           0             0                 0
## # ℹ 30 more rows
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
B1 <- filter(muestreo_1, BLOQUE=="1")
B1
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      1     0           0             0                 0
##  2      1     0           0             0                 0
##  3      1     0           0             0                 0
##  4      1     0           0.01          0.12              1
##  5      1     0           0             0                 0
##  6      1     0           0             0                 0
##  7      1     0           0             0                 0
##  8      1     0           0.01          0.12              1
##  9      1     0           0             0                 0
## 10      1     0           0             0                 0
B1 <- mean(B1$`% SEVERIDAD`)
B1
## [1] 0.024
B2<- filter(muestreo_1, BLOQUE=="2")
B2
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      2     0           0             0                 0
##  2      2     0           0             0                 0
##  3      2     0           0             0                 0
##  4      2     0           0.01          0.12              1
##  5      2     0           0             0                 0
##  6      2     0           0.01          0.12              1
##  7      2     0           0.01          0.12              1
##  8      2     0           0             0                 0
##  9      2     0           0             0                 0
## 10      2     0           0.01          0.12              1
B2 <- mean(B2$`% SEVERIDAD`)
B2
## [1] 0.048
B3 <- filter(muestreo_1, BLOQUE=="3")
B3
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      3     0           0.01          0.12              1
##  2      3     0           0             0                 0
##  3      3     0           0.01          0.12              1
##  4      3     0           0.01          0.12              1
##  5      3     0           0             0                 0
##  6      3     0           0             0                 0
##  7      3     0           0.01          0.12              1
##  8      3     0           0             0                 0
##  9      3     0           0.01          0.12              1
## 10      3     0           0             0                 0
B3 <- mean(B3$`% SEVERIDAD`)
B3
## [1] 0.06
B4 <- filter(muestreo_1, BLOQUE=="4")
B4
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      4     0           0             0                 0
##  2      4     0           0.01          0.12              1
##  3      4     0           0             0                 0
##  4      4     0           0.01          0.12              1
##  5      4     0           0.01          0.12              1
##  6      4     0           0.01          0.12              1
##  7      4     0           0             0                 0
##  8      4     0           0.01          0.12              1
##  9      4     0           0.01          0.12              1
## 10      4     0           0             0                 0
B4 <- mean(B4$`% SEVERIDAD`)
B4
## [1] 0.072
sev_1 <- mean(B1,B2,B3,B4)
I1 <- filter(muestreo_1, BLOQUE=="1")
I1
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      1     0           0             0                 0
##  2      1     0           0             0                 0
##  3      1     0           0             0                 0
##  4      1     0           0.01          0.12              1
##  5      1     0           0             0                 0
##  6      1     0           0             0                 0
##  7      1     0           0             0                 0
##  8      1     0           0.01          0.12              1
##  9      1     0           0             0                 0
## 10      1     0           0             0                 0
cantidad_0 <- sum(I1$`% INCIDENCIA`== 0.00)
cantidad_0
## [1] 8
cantidad_1 <- sum(I1$`% INCIDENCIA`== 0.01)
cantidad_1
## [1] 2
I1 <- 2/10
I1
## [1] 0.2
I2 <- filter(muestreo_1, BLOQUE=="2")
I2
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      2     0           0             0                 0
##  2      2     0           0             0                 0
##  3      2     0           0             0                 0
##  4      2     0           0.01          0.12              1
##  5      2     0           0             0                 0
##  6      2     0           0.01          0.12              1
##  7      2     0           0.01          0.12              1
##  8      2     0           0             0                 0
##  9      2     0           0             0                 0
## 10      2     0           0.01          0.12              1
cantidad_0 <- sum(I2$`% INCIDENCIA`== 0.00)
cantidad_0
## [1] 6
cantidad_1 <- sum(I2$`% INCIDENCIA`== 0.01)
cantidad_1
## [1] 4
I2 <- 4/10
I2
## [1] 0.4
I3 <- filter(muestreo_1, BLOQUE=="3")
I3
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      3     0           0.01          0.12              1
##  2      3     0           0             0                 0
##  3      3     0           0.01          0.12              1
##  4      3     0           0.01          0.12              1
##  5      3     0           0             0                 0
##  6      3     0           0             0                 0
##  7      3     0           0.01          0.12              1
##  8      3     0           0             0                 0
##  9      3     0           0.01          0.12              1
## 10      3     0           0             0                 0
cantidad_0 <- sum(I3$`% INCIDENCIA`== 0.00)
cantidad_0
## [1] 5
cantidad_1 <- sum(I3$`% INCIDENCIA`== 0.01)
cantidad_1
## [1] 5
I3 <- 5/10
I3
## [1] 0.5
I4 <- filter(muestreo_1, BLOQUE=="4")
I4
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      4     0           0             0                 0
##  2      4     0           0.01          0.12              1
##  3      4     0           0             0                 0
##  4      4     0           0.01          0.12              1
##  5      4     0           0.01          0.12              1
##  6      4     0           0.01          0.12              1
##  7      4     0           0             0                 0
##  8      4     0           0.01          0.12              1
##  9      4     0           0.01          0.12              1
## 10      4     0           0             0                 0
cantidad_0 <- sum(I4$`% INCIDENCIA`== 0.00)
cantidad_0
## [1] 4
cantidad_1 <- sum(I4$`% INCIDENCIA`== 0.01)
cantidad_1
## [1] 6
I4 <- 6/10
I4
## [1] 0.6
inc_1 <-mean(I1,I2,I3,I4) 
inc_1
## [1] 0.2
muestreo_2 <- read_excel("~/MANEJOS/MANEJO INTEGRADO DE ENFERMEDADES/PROYECTO GRUPAL/TABLA CAMPO-PDE-DUOPROTEKT-ROSA-L1.xlsx", 
    sheet = "EV CONTROL 1")
muestreo_2
## # A tibble: 40 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      1     0           0.01          0.38              2
##  2      1     0           0.01          0.63              3
##  3      1     0           0.01          0.38              2
##  4      1     0           0.01          0.38              2
##  5      1     0           0.01          0.63              3
##  6      1     0           0.01          0.12              1
##  7      1     0           0.01          0.12              1
##  8      1     0           0.01          0.12              1
##  9      1     0           0.01          0.12              1
## 10      1     0           0             0                 0
## # ℹ 30 more rows
B1_2 <- filter(muestreo_2, BLOQUE=="1")
B1_2
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      1     0           0.01          0.38              2
##  2      1     0           0.01          0.63              3
##  3      1     0           0.01          0.38              2
##  4      1     0           0.01          0.38              2
##  5      1     0           0.01          0.63              3
##  6      1     0           0.01          0.12              1
##  7      1     0           0.01          0.12              1
##  8      1     0           0.01          0.12              1
##  9      1     0           0.01          0.12              1
## 10      1     0           0             0                 0
B1_2 <- mean(B1_2$`% SEVERIDAD`)
B1_2
## [1] 0.288
B2_2<- filter(muestreo_2, BLOQUE=="2")
B2_2
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      2     0           0.01          0.12              1
##  2      2     0           0.01          0.12              1
##  3      2     0           0.01          0.38              2
##  4      2     0           0.01          0.38              2
##  5      2     0           0.01          0.38              2
##  6      2     0           0.01          0.38              2
##  7      2     0           0.01          0.38              2
##  8      2     0           0.01          0.12              1
##  9      2     0           0.01          0.63              3
## 10      2     0           0.01          0.38              2
B2_2 <- mean(B2_2$`% SEVERIDAD`)
B2_2
## [1] 0.327
B3_2 <- filter(muestreo_2, BLOQUE=="3")
B3_2
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      3     0           0.01          0.38              2
##  2      3     0           0.01          0.38              2
##  3      3     0           0.01          0.12              1
##  4      3     0           0.01          0.12              1
##  5      3     0           0.01          0.12              1
##  6      3     0           0.01          0.12              1
##  7      3     0           0.01          0.12              1
##  8      3     0           0.01          0.12              1
##  9      3     0           0             0                 0
## 10      3     0           0             0                 0
B3_2 <- mean(B3_2$`% SEVERIDAD`)
B3_2
## [1] 0.148
B4_2 <- filter(muestreo_2, BLOQUE=="4")
B4_2
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      4     0           0.01          0.38              2
##  2      4     0           0.01          0.38              2
##  3      4     0           0.01          0.12              1
##  4      4     0           0.01          0.38              2
##  5      4     0           0.01          0.38              2
##  6      4     0           0.01          0.12              1
##  7      4     0           0.01          0.12              1
##  8      4     0           0.01          0.38              2
##  9      4     0           0.01          0.38              2
## 10      4     0           0.01          0.38              2
B4_2 <- mean(B4_2$`% SEVERIDAD`)
B4_2
## [1] 0.302
sev_2 <- mean(B1_2,B2_2,B3_2,B4_2)
I1_2 <- filter(muestreo_2, BLOQUE=="1")
I1_2
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      1     0           0.01          0.38              2
##  2      1     0           0.01          0.63              3
##  3      1     0           0.01          0.38              2
##  4      1     0           0.01          0.38              2
##  5      1     0           0.01          0.63              3
##  6      1     0           0.01          0.12              1
##  7      1     0           0.01          0.12              1
##  8      1     0           0.01          0.12              1
##  9      1     0           0.01          0.12              1
## 10      1     0           0             0                 0
cantidad_0 <- sum(I1_2$`% INCIDENCIA`== 0.00)
cantidad_0
## [1] 1
cantidad_1 <- sum(I1_2$`% INCIDENCIA`== 0.01)
cantidad_1
## [1] 9
I1_2 <- 9/10
I1_2
## [1] 0.9
I2_2 <- filter(muestreo_2, BLOQUE=="2")
I2_2
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      2     0           0.01          0.12              1
##  2      2     0           0.01          0.12              1
##  3      2     0           0.01          0.38              2
##  4      2     0           0.01          0.38              2
##  5      2     0           0.01          0.38              2
##  6      2     0           0.01          0.38              2
##  7      2     0           0.01          0.38              2
##  8      2     0           0.01          0.12              1
##  9      2     0           0.01          0.63              3
## 10      2     0           0.01          0.38              2
cantidad_0 <- sum(I2_2$`% INCIDENCIA`== 0.00)
cantidad_0
## [1] 0
cantidad_1 <- sum(I2_2$`% INCIDENCIA`== 0.01)
cantidad_1
## [1] 10
I2_2 <- 10/10
I2_2
## [1] 1
I3_2 <- filter(muestreo_2, BLOQUE=="3")
I3_2
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      3     0           0.01          0.38              2
##  2      3     0           0.01          0.38              2
##  3      3     0           0.01          0.12              1
##  4      3     0           0.01          0.12              1
##  5      3     0           0.01          0.12              1
##  6      3     0           0.01          0.12              1
##  7      3     0           0.01          0.12              1
##  8      3     0           0.01          0.12              1
##  9      3     0           0             0                 0
## 10      3     0           0             0                 0
cantidad_0 <- sum(I3_2$`% INCIDENCIA`== 0.00)
cantidad_0
## [1] 2
cantidad_1 <- sum(I3_2$`% INCIDENCIA`== 0.01)
cantidad_1
## [1] 8
I3_2 <- 8/10
I3_2
## [1] 0.8
I4_2 <- filter(muestreo_2, BLOQUE=="4")
I4_2
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      4     0           0.01          0.38              2
##  2      4     0           0.01          0.38              2
##  3      4     0           0.01          0.12              1
##  4      4     0           0.01          0.38              2
##  5      4     0           0.01          0.38              2
##  6      4     0           0.01          0.12              1
##  7      4     0           0.01          0.12              1
##  8      4     0           0.01          0.38              2
##  9      4     0           0.01          0.38              2
## 10      4     0           0.01          0.38              2
cantidad_0 <- sum(I4_2$`% INCIDENCIA`== 0.00)
cantidad_0
## [1] 0
cantidad_1 <- sum(I4_2$`% INCIDENCIA`== 0.01)
cantidad_1
## [1] 10
I4_2 <- 10/10
I4_2
## [1] 1
inc_2 <-mean(I1_2,I2_2,I3_2,I4_2) 
inc_2
## [1] 0.9
muestreo_3 <- read_excel("~/MANEJOS/MANEJO INTEGRADO DE ENFERMEDADES/PROYECTO GRUPAL/TABLA CAMPO-PDE-DUOPROTEKT-ROSA-L1.xlsx", 
    sheet = "EV CONTROL 2")
B1_3 <- filter(muestreo_3, BLOQUE=="1")
B1_3
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      1     0           0.01          0.88              4
##  2      1     0           0.01          0.88              4
##  3      1     0           0.01          0.88              4
##  4      1     0           0.01          0.88              4
##  5      1     0           0.01          0.88              4
##  6      1     0           0.01          0.88              4
##  7      1     0           0.01          0.63              3
##  8      1     0           0.01          0.63              3
##  9      1     0           0.01          0.38              2
## 10      1     0           0.01          0.38              2
B1_3 <- mean(B1_3$`% SEVERIDAD`)
B1_3
## [1] 0.73
B2_3<- filter(muestreo_3, BLOQUE=="2")
B2_3
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      2     0           0.01          0.63              3
##  2      2     0           0.01          0.63              3
##  3      2     0           0.01          0.63              3
##  4      2     0           0.01          0.63              3
##  5      2     0           0.01          0.38              2
##  6      2     0           0.01          0.38              2
##  7      2     0           0.01          0.38              2
##  8      2     0           0.01          0.12              1
##  9      2     0           0.01          0.12              1
## 10      2     0           0.01          0.12              1
B2_3 <- mean(B2_3$`% SEVERIDAD`)
B2_3
## [1] 0.402
B3_3 <- filter(muestreo_3, BLOQUE=="3")
B3_3
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      3     0           0.01          0.63              3
##  2      3     0           0.01          0.63              3
##  3      3     0           0.01          0.63              3
##  4      3     0           0.01          0.63              3
##  5      3     0           0.01          0.63              3
##  6      3     0           0.01          0.38              2
##  7      3     0           0.01          0.38              2
##  8      3     0           0.01          0.38              2
##  9      3     0           0.01          0.38              2
## 10      3     0           0.01          0.38              2
B3_3 <- mean(B3_3$`% SEVERIDAD`)
B3_3
## [1] 0.505
B4_3 <- filter(muestreo_3, BLOQUE=="4")
B4_3
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      4     0           0.01          0.63              3
##  2      4     0           0.01          0.63              3
##  3      4     0           0.01          0.63              3
##  4      4     0           0.01          0.63              3
##  5      4     0           0.01          0.63              3
##  6      4     0           0.01          0.38              2
##  7      4     0           0.01          0.38              2
##  8      4     0           0.01          0.38              2
##  9      4     0           0.01          0.38              2
## 10      4     0           0.01          0.38              2
B4_3 <- mean(B4_3$`% SEVERIDAD`)
B4_3
## [1] 0.505
sev_3 <- mean(B1_3,B2_3,B3_3,B4_3)
I1_3 <- filter(muestreo_3, BLOQUE=="1")
I1_3
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      1     0           0.01          0.88              4
##  2      1     0           0.01          0.88              4
##  3      1     0           0.01          0.88              4
##  4      1     0           0.01          0.88              4
##  5      1     0           0.01          0.88              4
##  6      1     0           0.01          0.88              4
##  7      1     0           0.01          0.63              3
##  8      1     0           0.01          0.63              3
##  9      1     0           0.01          0.38              2
## 10      1     0           0.01          0.38              2
cantidad_0 <- sum(I1_3$`% INCIDENCIA`== 0.00)
cantidad_0
## [1] 0
cantidad_1 <- sum(I1_3$`% INCIDENCIA`== 0.01)
cantidad_1
## [1] 10
I1_3 <- 10/10
I1_3
## [1] 1
I2_3 <- filter(muestreo_3, BLOQUE=="2")
I2_3
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      2     0           0.01          0.63              3
##  2      2     0           0.01          0.63              3
##  3      2     0           0.01          0.63              3
##  4      2     0           0.01          0.63              3
##  5      2     0           0.01          0.38              2
##  6      2     0           0.01          0.38              2
##  7      2     0           0.01          0.38              2
##  8      2     0           0.01          0.12              1
##  9      2     0           0.01          0.12              1
## 10      2     0           0.01          0.12              1
cantidad_0 <- sum(I2_3$`% INCIDENCIA`== 0.00)
cantidad_0
## [1] 0
cantidad_1 <- sum(I2_3$`% INCIDENCIA`== 0.01)
cantidad_1
## [1] 10
I2_3 <- 10/10
I2_3
## [1] 1
I3_3 <- filter(muestreo_3, BLOQUE=="3")
I3_3
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      3     0           0.01          0.63              3
##  2      3     0           0.01          0.63              3
##  3      3     0           0.01          0.63              3
##  4      3     0           0.01          0.63              3
##  5      3     0           0.01          0.63              3
##  6      3     0           0.01          0.38              2
##  7      3     0           0.01          0.38              2
##  8      3     0           0.01          0.38              2
##  9      3     0           0.01          0.38              2
## 10      3     0           0.01          0.38              2
cantidad_0 <- sum(I3_3$`% INCIDENCIA`== 0.00)
cantidad_0
## [1] 0
cantidad_1 <- sum(I3_3$`% INCIDENCIA`== 0.01)
cantidad_1
## [1] 10
I3_3 <- 10/10
I3_3
## [1] 1
I4_3 <- filter(muestreo_3, BLOQUE=="4")
I4_3
## # A tibble: 10 × 5
##    BLOQUE   TTO `% INCIDENCIA` `% SEVERIDAD` `VALOR ESCALA`
##     <dbl> <dbl>          <dbl>         <dbl>          <dbl>
##  1      4     0           0.01          0.63              3
##  2      4     0           0.01          0.63              3
##  3      4     0           0.01          0.63              3
##  4      4     0           0.01          0.63              3
##  5      4     0           0.01          0.63              3
##  6      4     0           0.01          0.38              2
##  7      4     0           0.01          0.38              2
##  8      4     0           0.01          0.38              2
##  9      4     0           0.01          0.38              2
## 10      4     0           0.01          0.38              2
cantidad_0 <- sum(I4_3$`% INCIDENCIA`== 0.00)
cantidad_0
## [1] 0
cantidad_1 <- sum(I4_3$`% INCIDENCIA`== 0.01)
cantidad_1
## [1] 10
I4_3 <- 10/10
I4_3
## [1] 1
inc_3 <-mean(I1_3,I2_3,I3_3,I4_3) 
inc_3
## [1] 1
INCIDENCIA <- c(inc_1,inc_2,inc_3)
INCIDENCIA
## [1] 0.2 0.9 1.0
SEVERIDAD <- c(sev_1,sev_2,sev_3)
SEVERIDAD
## [1] 0.024 0.288 0.730
data_prev <- data.frame(INCIDENCIA,SEVERIDAD)*100
data_prev
##   INCIDENCIA SEVERIDAD
## 1         20       2.4
## 2         90      28.8
## 3        100      73.0
# Datos iniciales
x <- c(1, 2, 3)
y <- c(20, 90, 100)

# Crear un dataframe
data <- data.frame(x, y)

# Definir los nuevos valores de x
nuevos_x <- c(4, 5, 6, 7)

# Calcular los valores de y para los nuevos x
y_nuevos <- seq(from = 100, to = 100, length.out = length(nuevos_x) + 1)[-1]

# Mostrar los nuevos valores
y_nuevos
## [1] 100 100 100 100
# Combinar todos los datos
x_total <- c(x, nuevos_x)
y_total <- c(y, y_nuevos)

data_total <- data.frame(x = x_total, y = y_total)
data_total
##   x   y
## 1 1  20
## 2 2  90
## 3 3 100
## 4 4 100
## 5 5 100
## 6 6 100
## 7 7 100
library(ggplot2)

# Graficar los datos originales y la curva ajustada
ggplot(data_total, aes(x = x, y = y)) +
    geom_point(color = "blue", size = 3) + # Datos originales
    geom_line(aes(group=1), color="red") + # Línea que conecta todos los puntos ajustados
    labs(title="Ajuste de Valores desde 100 hasta 100",
         x="x",
         y="y") +
    theme_minimal()

# Datos iniciales
x <- c(1, 2, 3)
y <- c(2.4, 28.8, 73)

# Crear un dataframe
data <- data.frame(x, y)

# Definir los nuevos valores de x
nuevos_x <- c(4, 5, 6, 7)

# Calcular los valores de y para los nuevos x
y_nuevos <- seq(from = 73, to = 100, length.out = length(nuevos_x) + 1)[-1]

# Mostrar los nuevos valores
y_nuevos
## [1]  79.75  86.50  93.25 100.00
# Combinar todos los datos
x_total <- c(x, nuevos_x)
y_total <- c(y, y_nuevos)

data_total <- data.frame(x = x_total, y = y_total)
data_total
##   x      y
## 1 1   2.40
## 2 2  28.80
## 3 3  73.00
## 4 4  79.75
## 5 5  86.50
## 6 6  93.25
## 7 7 100.00
library(ggplot2)

# Graficar los datos originales y la curva ajustada
ggplot(data_total, aes(x = x, y = y)) +
    geom_point(color = "blue", size = 3) + # Datos originales
    geom_line(aes(group=1), color="red") + # Línea que conecta todos los puntos ajustados
    labs(title="Ajuste de Valores desde 73 hasta 100",
         x="x",
         y="y") +
    theme_minimal()

semana <- c(1,2,3,4,5,6,7)
severidad <- c(2.4,28.8,73,92,96,98,100)
incidencia <- c(20,90,100,100,100,100,100)
data_sim <- data.frame(semana,incidencia,severidad)
data_sim
##   semana incidencia severidad
## 1      1         20       2.4
## 2      2         90      28.8
## 3      3        100      73.0
## 4      4        100      92.0
## 5      5        100      96.0
## 6      6        100      98.0
## 7      7        100     100.0
# Graficar los datos originales y la curva ajustada
ggplot(data_sim, aes(x = semana, y = severidad)) +
    geom_point(color = "blue", size = 3) + # Datos originales
    geom_line(aes(group=1), color="red") + # Línea que conecta todos los puntos ajustados
    labs(title="datos a la semana 7",
         x="semanas",
         y="severidad") +
    theme_minimal()

# Graficar los datos originales y la curva ajustada
ggplot(data_sim, aes(x = semana, y = incidencia)) +
    geom_point(color = "blue", size = 3) + # Datos originales
    geom_line(aes(group=1), color="red") + # Línea que conecta todos los puntos ajustados
    labs(title="datos a la semana 7",
         x="semanas",
         y="incidencia") +
    theme_minimal()

data_sim
##   semana incidencia severidad
## 1      1         20       2.4
## 2      2         90      28.8
## 3      3        100      73.0
## 4      4        100      92.0
## 5      5        100      96.0
## 6      6        100      98.0
## 7      7        100     100.0
#Ajustar el modelo de Gompertz
modelo_gompertz <- nls(severidad ~ Asym * exp(-exp(b2 * (semana - b3))), 
                       data = data_sim,
                        start = list(Asym = 100, b2 = -1, b3 = 1))

#Resumen del modelo
summary(modelo_gompertz)
## 
## Formula: severidad ~ Asym * exp(-exp(b2 * (semana - b3)))
## 
## Parameters:
##      Estimate Std. Error t value Pr(>|t|)    
## Asym 99.03078    0.75141  131.79 1.99e-08 ***
## b2   -1.37432    0.06104  -22.52 2.30e-05 ***
## b3    2.14575    0.02210   97.10 6.74e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.191 on 4 degrees of freedom
## 
## Number of iterations to convergence: 9 
## Achieved convergence tolerance: 2.295e-06
# Predecir valores usando el modelo ajustado
tiempo_nuevo <- seq(min(data_sim$semana), max(data_sim$semana), length.out = 100)
predicciones <- predict(modelo_gompertz, newdata = data.frame(semana = tiempo_nuevo))

# Graficar los resultados
plot(data_sim$semana, data_sim$severidad, main = "Ajuste del Modelo de Gompertz", 
     xlab = "Tiempo", ylab = "Crecimiento", pch = 19)
lines(tiempo_nuevo, predicciones, col = "blue", lwd = 2)

# Ajustar el modelo logístico
modelo_logistico <- nls(severidad ~ a / (1 + b * exp(-c * semana)), 
                         data = data_sim,
                         start = list(a = max(severidad), b = 1, c = 0.1))

# Resumen del modelo
summary(modelo_logistico)
## 
## Formula: severidad ~ a/(1 + b * exp(-c * semana))
## 
## Parameters:
##   Estimate Std. Error t value Pr(>|t|)    
## a  97.8321     1.1280  86.727 1.06e-07 ***
## b 134.7618    43.0646   3.129 0.035209 *  
## c   1.9924     0.1316  15.138 0.000111 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.018 on 4 degrees of freedom
## 
## Number of iterations to convergence: 19 
## Achieved convergence tolerance: 6.097e-06
# Predecir valores usando el modelo ajustado
tiempo_nuevo <- seq(min(data_sim$semana), max(data_sim$semana), length.out = 100)
predicciones <- predict(modelo_logistico, newdata = data.frame(semana = tiempo_nuevo))

# Graficar los resultados
plot(data_sim$semana, data_sim$severidad, main = "Ajuste del Modelo Logístico", 
     xlab = "Tiempo", ylab = "Crecimiento", pch = 19)
lines(tiempo_nuevo, predicciones, col = "blue", lwd = 2)

library(readxl)
m_1 <- read_excel("~/MANEJOS/MANEJO INTEGRADO DE ENFERMEDADES/PROYECTO GRUPAL/ROSA.xlsx", 
    sheet = "EVA PREVIA")
MUESTREO <- c(1,1,1,1,1)
m_1 <- data.frame(MUESTREO,m_1)
m_1
##   MUESTREO TRATAMIENTO GRADO.SEVERIDAD INCIDENCIA
## 1        1           0           0.425       42.5
## 2        1           1           0.250       25.0
## 3        1           2           0.550       55.0
## 4        1           3           0.325       32.5
## 5        1           4           0.325       32.5
library(readxl)
m_2<- read_excel("~/MANEJOS/MANEJO INTEGRADO DE ENFERMEDADES/PROYECTO GRUPAL/ROSA.xlsx", 
    sheet = "EV CONTROL 1")
MUESTREO <- c(2,2,2,2,2)
m_2 <- data.frame(MUESTREO,m_2)
m_2
##   MUESTREO TRATAMIENTO GRADO.SEVERIDAD INCIDENCIA
## 1        2           0           1.525       92.5
## 2        2           1           1.325       75.0
## 3        2           2           1.325       80.0
## 4        2           3           0.925       72.5
## 5        2           4           1.250       80.0
library(readxl)
m_3 <- read_excel("~/MANEJOS/MANEJO INTEGRADO DE ENFERMEDADES/PROYECTO GRUPAL/ROSA.xlsx", 
    sheet = "EV CONTROL 2")
MUESTREO <- c(3,3,3,3,3)
m_3 <- data.frame(MUESTREO,m_3)
m_3
##   MUESTREO TRATAMIENTO GRADO.SEVERIDAD INCIDENCIA
## 1        3           0           2.625      100.0
## 2        3           1           2.325      100.0
## 3        3           2           1.900       95.0
## 4        3           3           1.600       97.5
## 5        3           4           1.975      100.0
data <- bind_rows(m_1,m_2,m_3)
data
##    MUESTREO TRATAMIENTO GRADO.SEVERIDAD INCIDENCIA
## 1         1           0           0.425       42.5
## 2         1           1           0.250       25.0
## 3         1           2           0.550       55.0
## 4         1           3           0.325       32.5
## 5         1           4           0.325       32.5
## 6         2           0           1.525       92.5
## 7         2           1           1.325       75.0
## 8         2           2           1.325       80.0
## 9         2           3           0.925       72.5
## 10        2           4           1.250       80.0
## 11        3           0           2.625      100.0
## 12        3           1           2.325      100.0
## 13        3           2           1.900       95.0
## 14        3           3           1.600       97.5
## 15        3           4           1.975      100.0
library(dplyr)
T0 <- filter(data, TRATAMIENTO=="0")
T0
##   MUESTREO TRATAMIENTO GRADO.SEVERIDAD INCIDENCIA
## 1        1           0           0.425       42.5
## 2        2           0           1.525       92.5
## 3        3           0           2.625      100.0
ggplot(T0, aes(x =  MUESTREO, y = SEVERIDAD)) +
    geom_point(color = "blue", size = 3) + # Datos originales
    geom_line(aes(group=1), color="red") + # Línea que conecta todos los puntos ajustados
    labs(title="SEVERIDAD DEL TRATAMIENTO CONTROL",
         x="x",
         y="y") +
    theme_minimal()

T1 <- filter(data, TRATAMIENTO=="1")
T1
##   MUESTREO TRATAMIENTO GRADO.SEVERIDAD INCIDENCIA
## 1        1           1           0.250         25
## 2        2           1           1.325         75
## 3        3           1           2.325        100
ggplot(T1, aes(x =  MUESTREO, y = SEVERIDAD)) +
    geom_point(color = "blue", size = 3) + # Datos originales
    geom_line(aes(group=1), color="red") + # Línea que conecta todos los puntos ajustados
    labs(title="SEVERIDAD DEL TRATAMIENTO T1: 0.2Kg/ha",
         x="x",
         y="y") +
    theme_minimal()

T2 <- filter(data, TRATAMIENTO=="2")
T2
##   MUESTREO TRATAMIENTO GRADO.SEVERIDAD INCIDENCIA
## 1        1           2           0.550         55
## 2        2           2           1.325         80
## 3        3           2           1.900         95
ggplot(T2, aes(x =  MUESTREO, y = SEVERIDAD)) +
    geom_point(color = "blue", size = 3) + # Datos originales
    geom_line(aes(group=1), color="red") + # Línea que conecta todos los puntos ajustados
    labs(title="SEVERIDAD DEL TRATAMIENTO 2: 0.3 Kg/ha",
         x="x",
         y="y") +
    theme_minimal()

T3 <- filter(data, TRATAMIENTO=="3")
T3
##   MUESTREO TRATAMIENTO GRADO.SEVERIDAD INCIDENCIA
## 1        1           3           0.325       32.5
## 2        2           3           0.925       72.5
## 3        3           3           1.600       97.5
ggplot(T3, aes(x =  MUESTREO, y = SEVERIDAD)) +
    geom_point(color = "blue", size = 3) + # Datos originales
    geom_line(aes(group=1), color="red") + # Línea que conecta todos los puntos ajustados
    labs(title="SEVERIDAD DEL TRATAMIENTO 3: 0.4 Kg/ha",
         x="x",
         y="y") +
    theme_minimal()

library(growthmodels)
## Warning: package 'growthmodels' was built under R version 4.3.3
datos <- data.frame(x = c(1, 2, 3), y = c(0.325, 1.250, 1.075))
#NO AJUSTA
# Ajustar el modelo de Gompertz
#modelo_gompertz <- nls(y ~ Asym * exp(-exp(b2 * (x - b3))), data = datos,
#                        start = list(Asym = 4, b2 = -0.1, b3 = 0.1))

# Resumen del modelo
#summary(modelo_gompertz)
#NO AJUSTA
# Ajustar el modelo logístico
#modelo_logistico <- nls(y ~ Asym / (1 + exp(-b2 * (x - b3))), 
                         #data = datos, 
                         #start = list(Asym = 4, b2 = 1, b3 = mean(datos$x)),
                         #control = nls.control(maxiter = 100, tol = 1e-5))

# Resumen del modelo
#summary(modelo_logistico)
# Ajustar el modelo monomolecular
modelo_monomolecular <- nls(y ~ A * (1 - exp(-k * x)), 
                             data = datos, 
                             start = list(A = 4, k = 0.1),
                             control = nls.control(maxiter = 100, tol = 1e-5))

summary(modelo_monomolecular)
## 
## Formula: y ~ A * (1 - exp(-k * x))
## 
## Parameters:
##   Estimate Std. Error t value Pr(>|t|)
## A   1.7610     2.7886   0.631    0.641
## k   0.3840     0.9831   0.391    0.763
## 
## Residual standard error: 0.4079 on 1 degrees of freedom
## 
## Number of iterations to convergence: 20 
## Achieved convergence tolerance: 7.266e-06
# Graficar los datos y el modelo ajustado
plot(datos$x, datos$y, main = "Ajuste del Modelo Monomolecular", xlab = "x", ylab = "y", pch = 16)
lines(datos$x, predict(modelo_monomolecular), col = "blue", lwd = 2)

datos$logy <- log(datos$y)
datos
##   x     y        logy
## 1 1 0.325 -1.12393010
## 2 2 1.250  0.22314355
## 3 3 1.075  0.07232066
# Ajustar el modelo lineal
modelo_lineal <- lm(logy ~ x, data = datos)

# Resumen del modelo
summary(modelo_lineal)
## 
## Call:
## lm(formula = logy ~ x, data = datos)
## 
## Residuals:
##       1       2       3 
## -0.2496  0.4993 -0.2496 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)  -1.4724     0.9341  -1.576    0.360
## x             0.5981     0.4324   1.383    0.398
## 
## Residual standard error: 0.6115 on 1 degrees of freedom
## Multiple R-squared:  0.6568, Adjusted R-squared:  0.3135 
## F-statistic: 1.913 on 1 and 1 DF,  p-value: 0.3985
# Predecir valores
predicciones <- exp(predict(modelo_lineal))

# Visualizar los resultados
plot(datos$x, datos$y, main = "Modelo Exponencial", xlab = "x", ylab = "y", pch = 19)
lines(datos$x, predicciones, col = "blue", lwd = 2)