library(psych)
## Warning: package 'psych' was built under R version 4.3.1
library(readxl)
## Warning: package 'readxl' was built under R version 4.3.1
Apio <- read_excel("C:\\Users\\USER\\Documents\\UNIVERSIDAD F\\2023-2\\Manejo Integrado de Enfermedades\\Datos Informe 2.xlsx", 
    sheet = "APIO", col_types = c("text", 
        "text", "text", "numeric", "numeric", 
        "numeric", "numeric"))
df1 <- data.frame(Apio)

#Analisis de datos Apio

descripcion=describeBy(df1$Altura, df1$Estrato)
print(descripcion)
## 
##  Descriptive statistics by group 
## group: Normal
##    vars  n  mean   sd median trimmed   mad min max range skew kurtosis   se
## X1    1 23 32.72 9.78   32.8   31.87 10.67  20  58    38 0.73    -0.03 2.04
## ------------------------------------------------------------ 
## group: Salino
##    vars n  mean    sd median trimmed  mad min  max range  skew kurtosis   se
## X1    1 9 26.11 11.49   28.5   26.11 12.6 6.2 39.2    33 -0.35    -1.54 3.83
med <- tapply(df1$Altura, df1$Estrato, mean)


boxplot(df1$Altura ~ df1$Estrato, horizontal = TRUE, col = c("#BCEE68", "#97FFFF"), xlab = "Altura (cm)", ylab = "Estrato", main = "Altura (cm) por Estrato")


points(y = 1:2, x = med, pch = 16, col = "#CD1076")


stripchart(df1$Altura ~ df1$Estrato, method = "jitter", pch = 16, add = TRUE, col = "blue")

med <- tapply(df1$Ramas, df1$Estrato, mean)


boxplot(df1$Ramas ~ df1$Estrato, horizontal = TRUE, col = c("#BCEE68", "#97FFFF"), xlab = "Numero de Ramas", ylab = "Estrato", main = "Numero de Ramas por Unidad Muestreal")


points(y = 1:2, x = med, pch = 16, col = "#CD1076")


stripchart(df1$Ramas ~ df1$Estrato, method = "jitter", pch = 16, add = TRUE, col = "blue")

library(readxl)
library(psych)

# Leer los datos
cebada <- read_excel("C:\\Users\\USER\\Documents\\UNIVERSIDAD F\\2023-2\\Manejo Integrado de Enfermedades\\Datos Informe 2.xlsx", 
    sheet = "CEBADA", col_types = c("text", "text", "text", "numeric", "numeric", "numeric", "numeric"))


df2 <- data.frame(cebada)


descripcion_Nmacollasplanta <- describeBy(df2$Nmacollasplanta)
## Warning in describeBy(df2$Nmacollasplanta): no grouping variable requested
print(descripcion_Nmacollasplanta)
##    vars  n mean   sd median trimmed  mad min max range skew kurtosis   se
## X1    1 32 5.48 2.63      5    5.27 2.97   2  11     9 0.58    -0.73 0.46
descripcion_Nhojasmacolla <- describeBy(df2$Nhojasmacolla)
## Warning in describeBy(df2$Nhojasmacolla): no grouping variable requested
print(descripcion_Nhojasmacolla)
##    vars  n mean   sd median trimmed mad min max range skew kurtosis  se
## X1    1 32 3.12 0.55      3    3.15   0   2   4     2 0.07    -0.03 0.1
descripcion_Altura <- describeBy(df2$Altura)
## Warning in describeBy(df2$Altura): no grouping variable requested
print(descripcion_Altura)
##    vars  n  mean   sd median trimmed  mad min  max range skew kurtosis   se
## X1    1 32 23.58 5.84  23.95   23.53 7.86  13 34.4  21.4 0.01    -1.31 1.03

#Analisis de datos Cebada

boxplot(df2$Altura~df2$Equipo,
        col = palette(RColorBrewer::brewer.pal(8, "Dark2")),xlab=("Media Total = 23,58 cm de Altura"),ylab=("ALtura (cm)"),main="Altura de plantas de Cebada ")

boxplot(df2$Nmacollasplanta~df2$Equipo,
        col = palette(RColorBrewer::brewer.pal(8, "Dark2")),xlab=("Media Total = 5,48 Macollas por planta"),ylab=("N° Macollas"),main="Numero de Macollas por Planta ")

boxplot(df2$Nhojasmacolla ~ df2$Equipo,
        col = palette(RColorBrewer::brewer.pal(8, "Dark2")),
        xlab = "Media Total = 3.12 Hojas por Macolla",
        ylab = "Altura (cm)",
        main = "Número de hojas por Macolla",
        ylim = c(1, 5))

#Analisis de datos Feijoa

library(readxl)
datos3<- read_excel("C:\\Users\\USER\\Documents\\UNIVERSIDAD F\\2023-2\\Manejo Integrado de Enfermedades\\Datos Informe 2.xlsx", 
    sheet = "FEIJOA", col_types = c("text", 
        "text", "text", "numeric", "numeric"))
df3 = data.frame(datos3)
descripcionflores <- describeBy(df3$Nflores)
## Warning in describeBy(df3$Nflores): no grouping variable requested
print(descripcionflores)
##    vars  n mean  sd median trimmed   mad min max range skew kurtosis   se
## X1    1 40  7.2 7.3    7.5    6.31 11.12   0  27    27 0.65    -0.41 1.15
descripcionfruto <- describeBy(df3$Nfrutos)
## Warning in describeBy(df3$Nfrutos): no grouping variable requested
print(descripcionfruto)
##    vars  n  mean    sd median trimmed  mad min max range skew kurtosis   se
## X1    1 40 10.95 20.65      2    6.19 2.97   0 110   110 3.04    10.86 3.26
med <- tapply(df3$Nflores,df3$Estrato,mean)


boxplot(df3$Nflores ~ df3$Estrato, horizontal = TRUE, col = c("#BCEE68", "#97FFFF"), xlab = "Media Total = 7,2 Flores abiertas por planta", ylab = "Estrato", main = "Numero de Flores abiertas por planta") 


points(y = 1:2, x = med, pch = 16, col = "#CD1076")


stripchart(df3$Nflores ~ df3$Estrato, method = "jitter", pch = 16, add = TRUE, col = "blue")

med <- tapply(df3$Nfrutos,df3$Estrato,mean)


boxplot(df3$Nfrutos ~ df3$Estrato, horizontal = TRUE, col = c("#BCEE68", "#97FFFF"), xlab = "Numero de Frutos", ylab = "Estrato", main = "Numero de Frutos por planta") 


points(y = 1:2, x = med, pch = 16, col = "#CD1076")


stripchart(df3$Nfrutos ~ df3$Estrato, method = "jitter", pch = 16, add = TRUE, col = "blue")

#Analisis de Varianza ANOVA Primer muestreo y Segundo Muestreo

library(readxl)
IA <- read_excel("C:\\Users\\USER\\Documents\\UNIVERSIDAD F\\2023-2\\Manejo Integrado de Enfermedades\\Datos Informe 2.xlsx", 
    sheet = "IA", col_types = c("text", "text", 
        "text", "numeric"))
df4 = data.frame(IA)
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.1
## 
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
## 
##     %+%, alpha
ggplot(data = df4, aes(x = Equipo, y = Incidencia)) +
  geom_point() +
  facet_grid(Estrato ~ .) +
  ylab(expression(bold("Incidencia (%)"))) +
  labs(title = expression(bold("Incidencia (%) de Septoria sp en Plantas de Apio")))

#Media normal= 86,96% y Media Salino = 100%

library(psych)
descripcionincidencia <- describeBy(df4$Incidencia, df4$Estrato)
print(descripcionincidencia)
## 
##  Descriptive statistics by group 
## group: Normal
##    vars  n  mean    sd median trimmed mad min max range  skew kurtosis   se
## X1    1 23 86.96 34.44    100   94.74   0   0 100   100 -2.05     2.32 7.18
## ------------------------------------------------------------ 
## group: Salino
##    vars n mean sd median trimmed mad min max range skew kurtosis se
## X1    1 9  100  0    100     100   0 100 100     0  NaN      NaN  0
library(readxl)
IA <- read_excel("C:\\Users\\USER\\Documents\\UNIVERSIDAD F\\2023-2\\Manejo Integrado de Enfermedades\\Datos Informe 2.xlsx", 
    sheet = "IC", col_types = c("text", "text", 
        "numeric"))
df5 = data.frame(IA)
boxplot(df5$Incidencia ~ df5$Equipo,
        col = palette(RColorBrewer::brewer.pal(8, "Dark2")),
        xlab = "Media Total = 23.28 % de Incidencia de la Enfermedad",
        ylab = "Incidencia (%)",
        main = "Incidencia (%) de Rhynchosporium sp. en plantas de Cebada",
        ylim = c(10, 100))

library(psych)
dic <- describeBy(df5$Incidencia, df5$Estrato)
## Warning in describeBy(df5$Incidencia, df5$Estrato): no grouping variable
## requested
print(dic)
##    vars  n  mean    sd median trimmed  mad min max range skew kurtosis   se
## X1    1 32 23.28 23.42  18.85   19.46 16.5   0 100   100 1.48     2.14 4.14
library(readxl)
IC <- read_excel("C:\\Users\\USER\\Documents\\UNIVERSIDAD F\\2023-2\\Manejo Integrado de Enfermedades\\Datos Informe 2.xlsx", 
    sheet = "IF", col_types = c("text", "text","text", 
        "numeric"))
df6 = data.frame(IC)

library(psych)
dif <- describeBy(df6$Incidencia, df6$Estrato)
print(dif)
## 
##  Descriptive statistics by group 
## group: 17 años
##    vars  n mean   sd median trimmed mad min max range skew kurtosis   se
## X1    1 20 2.45 8.15      0       0   0   0  34    34 3.06     8.54 1.82
## ------------------------------------------------------------ 
## group: 20 años
##    vars  n  mean    sd median trimmed   mad min max range  skew kurtosis   se
## X1    1 20 44.41 27.31  46.19   45.16 29.74   0  83    83 -0.17     -1.3 6.11
med <- tapply(df6$Incidencia,df6$Estrato,mean)


boxplot(df6$Incidencia ~ df6$Estrato, horizontal = TRUE, col = c("#BCEE68", "#97FFFF"), xlab = "Incidencia (%)", ylab = "Estrato", main = "Incidencia (%) de la enfermedad en arboles de Feijoa") 


points(y = 1:2, x = med, pch = 16, col = "#CD1076")


stripchart(df6$Incidencia ~ df6$Estrato, method = "jitter", pch = 16, add = TRUE, col = "blue")