UNIVERSIDAD CENTRAL DEL ECUADOR
ESTUDIO ESTADÍSTICO DE LA CONTAMINACIÓN DEL SUELO Y SU IMPACTO EN LA SALUD
FECHA: 19/11/2025
# =========================
# ESTADÍSTICA Descriptiva
# Fecha: 19/11/2025
# =========================
library(gt)
library(dplyr)
# -------------------------
# Cargar datos
# -------------------------
setwd("C:/Users/Alexander/Downloads")
datos <- read.csv(
"soil_pollution_diseases.csv",
sep = ",",
stringsAsFactors = FALSE
)
# =========================
# TABLAS CUALITATIVAS NOMINALES
# =========================
Enfermedad <- datos$Disease_Type
TDF_Enfermedad <- data.frame(table(Enfermedad))
ni <- TDF_Enfermedad$Freq
hi <- round((ni / sum(ni)) * 100, 2)
TDF_Enfermedad <- data.frame(
Enfermedad = TDF_Enfermedad$Enfermedad,
ni,
hi
)
Summary <- data.frame(
Enfermedad = "TOTAL",
ni = sum(ni),
hi = 100
)
TDF_Enfermedad_suma <- rbind(TDF_Enfermedad, Summary)
colnames(TDF_Enfermedad_suma) <- c("Enfermedad", "ni", "hi(%)")
# =========================
# TABLA
# =========================
TDF_Enfermedad_suma %>%
gt() %>%
tab_header(
title = md("*Tabla Nro. 8*"),
subtitle = md("**Tabla de distribución del tipo de enfermedad**")
) %>%
tab_source_note(
source_note = md("Autor: Grupo 3")
) %>%
tab_options(
table.border.top.color = "black",
table.border.bottom.color = "black",
table.border.top.style = "solid",
table.border.bottom.style = "solid",
column_labels.border.top.color = "black",
column_labels.border.bottom.color = "black",
column_labels.border.bottom.width = px(2),
row.striping.include_table_body = TRUE,
heading.border.bottom.color = "black",
heading.border.bottom.width = px(2),
table_body.hlines.color = "gray",
table_body.border.bottom.color = "black"
)
| Tabla Nro. 8 | ||
| Tabla de distribución del tipo de enfermedad | ||
| Enfermedad | ni | hi(%) |
|---|---|---|
| Cancer | 622 | 20.73 |
| Gastrointestinal Disease | 578 | 19.27 |
| Neurological Disorder | 597 | 19.90 |
| Respiratory Issues | 581 | 19.37 |
| Skin Disease | 622 | 20.73 |
| TOTAL | 3000 | 100.00 |
| Autor: Grupo 3 | ||
# =========================
# GRÁFICAS
# =========================
# Diagrama de barras local ni
barplot(ni,
main = "Gráfica N°36: Distribución del tipo de enfermedad",
xlab = "Enfermedad",
ylab = "Cantidad",
col = "red",
ylim = c(0,600),
las = 1,
cex.names = 0.6,
names.arg = TDF_Enfermedad$Enfermedad)
# Diagrama de barras global ni
barplot(ni,
main = "Gráfica N°37: Distribución del tipo de enfermedad",
xlab = "Enfermedad",
ylab = "Cantidad",
col = "skyblue",
ylim = c(0,3000),
las = 1,
cex.names = 0.6,
names.arg = TDF_Enfermedad$Enfermedad)
# Diagrama de barras local hi(%)
barplot(hi,
main = "Gráfica N°38: Distribución porcentual del tipo de enfermedad",
xlab = "Enfermedad",
ylab = "Porcentaje",
col = "green",
ylim = c(0,20),
las = 1,
cex.names = 0.6,
names.arg = TDF_Enfermedad$Enfermedad)
# Diagrama de barras global hi(%)
barplot(hi,
main = "Gráfica N°39: Distribución porcentual del tipo de enfermedad",
xlab = "Enfermedad",
ylab = "Porcentaje",
col = "blue",
ylim = c(0,100),
las = 1,
cex.names = 0.6,
names.arg = TDF_Enfermedad$Enfermedad)
# =========================
# DIAGRAMA CIRCULAR
# =========================
etiquetas <- paste0(hi, " %")
colores <- c("yellow", "khaki1", "gold", "orange", "darkorange", "red")
par(mar = c(2, 2, 4, 6))
pie(
hi,
labels = etiquetas,
col = colores,
main = "Gráfica N°40 Distribución porcentual del tipo de enfermedad",
cex = 1
)
legend(
"topright",
legend = TDF_Enfermedad$Enfermedad,
fill = colores,
title = "Leyenda",
cex = 0.5,
xpd = TRUE
)
# =========================
# INDICADORES
# =========================
moda <- function(x) {
frec <- table(x)
names(frec)[which.max(frec)]
}
moda_enfermedad <- moda(Enfermedad)
moda_enfermedad
## [1] "Cancer"
# =========================
# CONCLUSIÓN
# =========================
cat("El tipo de enfermedad más frecuente es:", moda_enfermedad)
## El tipo de enfermedad más frecuente es: Cancer