ANÁLISIS ESTADÍSTICO
1. CARGA DE LIBRERÍAS Y DATOS
#=========================ENCABEZADO================================
# TEMA: ESTADÍSTICA INFERENCIAL- CUENCA
# AUTOR: GRUPO 3
# FECHA: 03-2026
#========================================================================
# 1. CARGA DE LIBRERÍAS Y DATOS
library(gt)
library(dplyr)
setwd("C:/Users/HP/Documents/PROYECTO ESTADISTICA/RStudio")
datos <- read.csv("tablap.csv", header = TRUE, dec = ",", sep = ";")
2. TABLA DE DISTRIBUCIÓN DE PROBABILIDAD
# 2. TABLA DE DISTRIBUCIÓN DE PROBABILIDAD
Cuenca_Raw <- datos$Basin
Cuenca_Limpia <- ifelse(
is.na(Cuenca_Raw) | trimws(Cuenca_Raw) == "",
"Sin Registro",
trimws(Cuenca_Raw)
)
CUENCA <- factor(Cuenca_Limpia)
TablaCUENCA <- as.data.frame(table(CUENCA))
colnames(TablaCUENCA) <- c("CUENCA", "ni")
TablaCUENCA$hi <- round(TablaCUENCA$ni / sum(TablaCUENCA$ni), 4)
TablaCUENCA$P <- round(TablaCUENCA$hi * 100, 2)
Total <- data.frame(
CUENCA = "TOTAL",
ni = sum(TablaCUENCA$ni),
hi = sum(TablaCUENCA$hi),
P = sum(TablaCUENCA$P)
)
TablaFinalC <- rbind(TablaCUENCA, Total)
# Aplicación de gt para la tabla de probabilidad
TablaFinalC %>%
gt() %>%
tab_header(
title = md("**Tabla Nº1. Distribución de probabilidad por Cuenca
de los pozos de gas natural en Nuevo México**"),
) %>%
tab_style(
style = list(cell_fill(color = "lightgray"), cell_text(weight = "bold")),
locations = cells_body(rows = CUENCA == "TOTAL")
)
| Tabla Nº1. Distribución de probabilidad por Cuenca
de los pozos de gas natural en Nuevo México |
| CUENCA |
ni |
hi |
P |
| Permian |
3277 |
0.2609 |
26.09 |
| Rotan Ski |
655 |
0.0521 |
5.21 |
| San Juan |
8629 |
0.6870 |
68.70 |
| TOTAL |
12561 |
1.0000 |
100.00 |
3. GRÁFICA DE DISTRIBUCIÓN DE PROBABILIDAD
# 3. GRÁFICAS DE DISTRIBUCIÓN DE PROBABILIDAD
P_global <- as.numeric(TablaFinalC$P[1:(nrow(TablaFinalC)-1)])
Nombres_C <- TablaFinalC$CUENCA[1:(nrow(TablaFinalC)-1)]
color_barras_abs <- "#76D7C4"
barplot(
P_global,
main = "Gráfica Nº1: Distribución de probabilidad
de las cuencas de gas natural en Nuevo México",
cex.main = 1.3,
xlab = "Cuenca",
ylab = "Probabilidad (%)",
col = color_barras_abs,
names.arg = Nombres_C,
cex.names = 0.7,
ylim = c(0, 100),
las = 1
)

4. CÁLCULO DE PROBABILIDAD
# 4. CÁLCULO DE PROBABILIDAD
tabla_sin_total <- TablaFinalC[TablaFinalC$CUENCA != "TOTAL", ]
cuenca_mayor <- tabla_sin_total$CUENCA[which.max(tabla_sin_total$P)]
prob_mayor <- tabla_sin_total$P[which.max(tabla_sin_total$P)]
plot.new()
plot.window(xlim = c(0, 100), ylim = c(0, 1))
rect(10, 0.4, 90, 0.6, col = "#E5E7E9", border = NA)
ancho_barra <- (prob_mayor / 100) * 80
rect(10, 0.4, 10 + ancho_barra, 0.6, col = "#76D7C4", border = NA)
text(50, 0.85, "CÁLCULO DE PROBABILIDAD", cex = 1.5, font = 2, col = "#2A9D8F")
text(50, 0.75, "¿En qué cuenca existe la mayor probabilidad", cex = 1.3, font = 3)
text(50, 0.65, "de actividad de pozos de gas natural?", cex = 1.3, font = 3)
text(10 + ancho_barra/2, 0.5, paste0(prob_mayor, "%"), cex = 1.6, font = 2, col = "white")
text(50, 0.25, paste("R:", cuenca_mayor), cex = 1.4, font = 2, col = "#1F618D")
rect(10, 0.4, 90, 0.6, border = "#2A9D8F", lwd = 2)

5. CONCLUSIÓN
# 5. CONCLUSIÓN
cat(paste0("Los resultados muestran que la cuenca ", cuenca_mayor,
" es el tipo de depósito con mayor probabilidad con un ",
prob_mayor, " %."))
## Los resultados muestran que la cuenca San Juan es el tipo de depósito con mayor probabilidad con un 68.7 %.