FECHA: 24/12/2025
#Estadistica Inferencial
#24/12/2025
#Cargar Datos
library(gt)
library(dplyr)
datos<-read.csv("soil_pollution_diseases.csv",header = TRUE,dec = ".",
sep = ",")
#Tipo de fuente de agua
Enfermedad <- datos$Disease_Type
TDF_Enfermedad <-data.frame(table(Enfermedad))
ni <- TDF_Enfermedad$Freq
hi <- round((ni / sum(ni)) * 100, 2)
Pi <- hi
Enfermedad <- TDF_Enfermedad$Enfermedad
TDF_Enfermedad <- data.frame(Enfermedad, ni, hi, Pi)
Summary <- data.frame(
Enfermedad = "TOTAL",
ni = sum(ni),
hi = 100,
Pi = 100
)
TDF_Enfermedad_Suma <- rbind(TDF_Enfermedad, Summary)
colnames(TDF_Enfermedad_Suma) <- c("Enfermedad", "ni", "hi(%)", "Pi(%)")
# TABLA
TDF_Enfermedad_Suma %>%
gt() %>%
tab_header(
title = md("*Tabla Nro. 3*"),
subtitle = md("Tabla de distribución y probabilidades de las enfermedades")
) %>%
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. 3 |
| Tabla de distribución y probabilidades de las enfermedades |
| Enfermedad |
ni |
hi(%) |
Pi(%) |
| Cancer |
622 |
20.73 |
20.73 |
| Gastrointestinal Disease |
578 |
19.27 |
19.27 |
| Neurological Disorder |
597 |
19.90 |
19.90 |
| Respiratory Issues |
581 |
19.37 |
19.37 |
| Skin Disease |
622 |
20.73 |
20.73 |
| TOTAL |
3000 |
100.00 |
100.00 |
| Autor: Grupo 3 |
barplot(hi, main = "Gráfica N°5: Distribución porcentual de
las enfemedades",
xlab = "Enfermedad",
ylab = "Porcentaje",
col = "green",
ylim = c(0,26),
las = 1,
cex.names = 0.6,
names.arg = TDF_Enfermedad$Enfermedad)

barplot(hi, main = "Gráfica N°6: Distribución para la probabilidad de
las enfermedades",
xlab = "Enfermedad",
ylab = "Probabilidad",
col = "green",
ylim = c(0,26),
las = 1,
cex.names = 0.6,
names.arg = TDF_Enfermedad$Enfermedad)

# ¿ Cuál es la probabilidad de contrar cancer?
prob_cancer <- TDF_Enfermedad$Pi[
TDF_Enfermedad$Enfermedad == "Cancer"
]
cat(
"¿Cuál es la probabilidad de contraer cancer?\n",
"La probabilidad de contraer cancer es de",
prob_cancer, "%.\n"
)
## ¿Cuál es la probabilidad de contraer cancer?
## La probabilidad de contraer cancer es de 20.73 %.