library(psych)
library(readxl)
library(ggplot2)
## 
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
## 
##     %+%, alpha
library(lattice)

######  Análisis descriptivo nmérico (Estrato 1 salino, estrato 2 normal)######## 
Primera1 <- read_xlsx("Apio uno.xlsx")
attach(Primera1)
INCIDENCIA <- as.numeric(INCIDENCIA)


psych::describe(INCIDENCIA)
##    vars  n  mean    sd median trimmed   mad  min max range  skew kurtosis   se
## X1    1 32 69.25 30.27     75    72.7 37.06 0.83 100 99.17 -0.65    -0.75 5.35
describe.by(INCIDENCIA, group = ESTRATO)
## Warning: describe.by is deprecated.  Please use the describeBy function
## 
##  Descriptive statistics by group 
## group: 1
##    vars n  mean sd median trimmed   mad  min max range  skew kurtosis    se
## X1    1 8 64.69 37  66.66   64.69 49.42 0.83 100 99.17 -0.39     -1.5 13.08
## ------------------------------------------------------------ 
## group: 2
##    vars  n  mean    sd median trimmed   mad min max range  skew kurtosis   se
## X1    1 24 70.77 28.44     75   73.67 31.13 8.3 100  91.7 -0.67    -0.71 5.81
(sd <- sd(INCIDENCIA))
## [1] 30.26995
(meann <- mean(INCIDENCIA))
## [1] 69.24781
(Coeficientevar <- sd/meann)
## [1] 0.437125
#################
##### MODA #####

library(modeest)
## Registered S3 method overwritten by 'rmutil':
##   method         from 
##   plot.residuals psych
mlv(INCIDENCIA, method = "meanshift") 
## [1] 93.82458
## attr(,"iterations")
## [1] 19
##### Gráficas de análisis descriptivo ####

med <- tapply(INCIDENCIA,ESTRATO,mean)
boxplot(INCIDENCIA~ESTRATO, horizontal = T, col=c("lightgreen", "lightblue"), xlab="INCIDENCIA (%)", ylab="ESTRATO", main="Incidencia de septoriasis en apio") 
points(y=1:2, x=med, pch=16, col="red")
rug(INCIDENCIA[which(ESTRATO=="salado")],lwd = 3,side = 3,col="darkgreen")
rug(INCIDENCIA[which(ESTRATO=="normal")],lwd = 3,side = 1,col="blue")
stripchart(INCIDENCIA~ESTRATO, method = "jitter", pch = 16, add = T, col = "blue")