1 Configuración y Carga de Datos

datos_originales <- readr::read_delim(
  ruta, delim=delimitador, trim_ws=TRUE, show_col_types=FALSE,
  name_repair="minimal", col_types=readr::cols(.default=readr::col_character())
)
## Carga exitosa: 47.501 registros y 56 variables.

2 Extracción y Limpieza de la Variable

valores_txt <- stringr::str_squish(as.character(datos_originales[[columna_md]]))
valores_txt[toupper(valores_txt) %in% c("", "NA", "N/A", "NULL")] <- NA
valores_limpios <- gsub(",", "", valores_txt)
Variable <- suppressWarnings(as.numeric(valores_limpios))

n_total   <- length(Variable)
n_nulos   <- sum(is.na(Variable))
Variable  <- Variable[!is.na(Variable)]
N <- length(Variable)
n_ceros <- sum(Variable == 0)
if (N == 0L) stop("No hay registros válidos de Measured Depth.")

Minimo_real <- min(Variable)
Maximo_real <- max(Variable)

cat("Variable analizada: Measured Depth, ft | Unidad: pies (ft)\n")
## Variable analizada: Measured Depth, ft | Unidad: pies (ft)
cat("Observaciones útiles (N):", fmt_entero(N), "| Nulos omitidos:", fmt_entero(n_nulos), "| Valores en 0:", fmt_entero(n_ceros), "\n")
## Observaciones útiles (N): 47.496 | Nulos omitidos: 5 | Valores en 0: 14.679
cat("Mínimo:", fmt_num(Minimo_real, 0), "| Máximo:", fmt_num(Maximo_real, 0), "pies\n")
## Mínimo: 0 | Máximo: 15921 pies

3 Identificación de la Variable

Escala: la profundidad medida es cuantitativa continua de escala de razón (el 0 ft indica ausencia de profundidad). El conjunto incluye 14.679 pozos con valor 0 ft (30.91%), que se mantienen en el análisis.

VARIABLE TIPO ESCALA DE MEDICIÓN UNIDAD DE MEDIDA UNIDAD DE ANÁLISIS REGISTROS VÁLIDOS (N)
MEASURED DEPTH (Profundidad medida, ft) Cuantitativa continua Razón Pies (ft) Pozo regulado 47.496

4 Tabla de Distribución de Frecuencias

cortes_int <- pretty(c(Minimo_real, Maximo_real), n=15)       # límites redondos calculados por R
if (max(cortes_int) < Maximo_real) cortes_int <- c(cortes_int, max(cortes_int) + (cortes_int[2] - cortes_int[1]))
K_real       <- length(cortes_int) - 1
Amplitud_int <- cortes_int[2] - cortes_int[1]

inter_int <- cut(Variable, breaks=cortes_int, include.lowest=TRUE, right=FALSE)
ni_int    <- as.vector(table(inter_int))

hi_int_unit <- ni_int / N
hi_int_perc <- hi_int_unit * 100

TDF_Enteros <- data.frame(
  Li = cortes_int[1:K_real],
  Ls = cortes_int[2:(K_real + 1)],
  MC = (cortes_int[1:K_real] + cortes_int[2:(K_real + 1)]) / 2,
  ni = ni_int,
  hi_unit = hi_int_unit,
  hi_perc = hi_int_perc,
  Ni_asc  = cumsum(ni_int),
  Ni_desc = rev(cumsum(rev(ni_int))),
  Hi_asc_perc  = cumsum(hi_int_perc),
  Hi_desc_perc = rev(cumsum(rev(hi_int_perc)))
)
stopifnot(sum(TDF_Enteros$ni) == N)

cat("Número de clases (k):", K_real, "\n")
## Número de clases (k): 16
cat("Amplitud de clase:", Amplitud_int, "pies\n")
## Amplitud de clase: 1000 pies
tabla_final <- data.frame(
  "LÍM. INF (ft)"=fmt_num(TDF_Enteros$Li, 0),
  "LÍM. SUP (ft)"=fmt_num(TDF_Enteros$Ls, 0),
  "MARCA DE CLASE (xᵢ)"=fmt_num(TDF_Enteros$MC, 1),
  "nᵢ"=fmt_entero(TDF_Enteros$ni),
  "hᵢ"=sprintf("%.4f", TDF_Enteros$hi_unit),
  "hᵢ (%)"=sprintf("%.2f", TDF_Enteros$hi_perc),
  "Nᵢ (↑)"=fmt_entero(TDF_Enteros$Ni_asc),
  "Nᵢ (↓)"=fmt_entero(TDF_Enteros$Ni_desc),
  "Hᵢ (% ↑)"=sprintf("%.2f", TDF_Enteros$Hi_asc_perc),
  "Hᵢ (% ↓)"=sprintf("%.2f", TDF_Enteros$Hi_desc_perc),
  check.names=FALSE
)
tabla_final <- rbind(tabla_final, data.frame(
  "LÍM. INF (ft)"="TOTAL", "LÍM. SUP (ft)"="", "MARCA DE CLASE (xᵢ)"="",
  "nᵢ"=fmt_entero(sum(TDF_Enteros$ni)), "hᵢ"="1.0000", "hᵢ (%)"="100.00",
  "Nᵢ (↑)"="", "Nᵢ (↓)"="", "Hᵢ (% ↑)"="", "Hᵢ (% ↓)"="", check.names=FALSE
))
cat(crear_cuadro(tabla_final, 1,
  "Distribución de frecuencias de los pozos regulados según la profundidad medida (ft), Nueva York, 1860 - 2026",
  desplazamiento=(K_real > 15L), align=c("c","c","c",rep("r",7))))
Cuadro N° 1: Distribución de frecuencias de los pozos regulados según la profundidad medida (ft), Nueva York, 1860 - 2026
LÍM. INF (ft) LÍM. SUP (ft) MARCA DE CLASE (xᵢ) nᵢ hᵢ hᵢ (%) Nᵢ (↑) Nᵢ (↓) Hᵢ (% ↑) Hᵢ (% ↓)
0 1000 500.0 18.642 0.3925 39.25 18.642 47.496 39.25 100.00
1000 2000 1500.0 17.541 0.3693 36.93 36.183 28.854 76.18 60.75
2000 3000 2500.0 4.639 0.0977 9.77 40.822 11.313 85.95 23.82
3000 4000 3500.0 3.343 0.0704 7.04 44.165 6.674 92.99 14.05
4000 5000 4500.0 2.456 0.0517 5.17 46.621 3.331 98.16 7.01
5000 6000 5500.0 294 0.0062 0.62 46.915 875 98.78 1.84
6000 7000 6500.0 107 0.0023 0.23 47.022 581 99.00 1.22
7000 8000 7500.0 121 0.0025 0.25 47.143 474 99.26 1.00
8000 9000 8500.0 65 0.0014 0.14 47.208 353 99.39 0.74
9000 10000 9500.0 75 0.0016 0.16 47.283 288 99.55 0.61
10000 11000 10500.0 57 0.0012 0.12 47.340 213 99.67 0.45
11000 12000 11500.0 78 0.0016 0.16 47.418 156 99.84 0.33
12000 13000 12500.0 48 0.0010 0.10 47.466 78 99.94 0.16
13000 14000 13500.0 21 0.0004 0.04 47.487 30 99.98 0.06
14000 15000 14500.0 6 0.0001 0.01 47.493 9 99.99 0.02
15000 16000 15500.0 3 0.0001 0.01 47.496 3 100.00 0.01
TOTAL 47.496 1.0000 100.00

Fuente: Oil, Gas & Other Regulated Wells: Beginning 1860.

Interpretación: el intervalo de profundidad con mayor concentración de pozos es [0 – 1000) pies, con 18.642 pozos (39.25% de los 47.496 registros válidos). Hasta los 2000 pies se acumula al menos el 50 % de los pozos.

5 Representación Gráfica

5.1 Gráfica N° 1 — Frecuencia absoluta (nᵢ) local

ggplot2::ggplot(tabla_graf, ggplot2::aes(x=intervalo, y=ni, fill=intervalo)) +
  ggplot2::geom_col(width=.72, color="#244861", linewidth=.36) +
  ggplot2::geom_text(ggplot2::aes(label=fmt_entero(ni)), vjust=-.48,
                     size=4.5, fontface="bold", color="#15364C") +
  ggplot2::scale_fill_manual(values=colores) +
  ggplot2::scale_y_continuous(limits=c(0, limite_ni_local), labels=fmt_entero,
                              expand=ggplot2::expansion(mult=c(0,0))) +
  ggplot2::coord_cartesian(clip="off") +
  ggplot2::labs(title="Gráfica N° 1: Frecuencia absoluta (nᵢ) local",
                x="Profundidad medida (ft)", y="Frecuencia absoluta (nᵢ)", caption=fuente_graficas) +
  tema_barras

5.2 Gráfica N° 2 — Frecuencia absoluta (nᵢ) global

ggplot2::ggplot(tabla_graf, ggplot2::aes(x=intervalo, y=ni)) +
  ggplot2::geom_col(fill=color_barras, color="#244861", width=.72, linewidth=.36) +
  ggplot2::geom_text(ggplot2::aes(label=fmt_entero(ni)), vjust=-.48,
                     size=4.5, fontface="bold", color="#15364C") +
  ggplot2::scale_y_continuous(limits=c(0, limite_ni_global), labels=fmt_entero,
                              expand=ggplot2::expansion(mult=c(0,0))) +
  ggplot2::coord_cartesian(clip="off") +
  ggplot2::labs(title="Gráfica N° 2: Frecuencia absoluta (nᵢ) global",
                x="Profundidad medida (ft)", y="Frecuencia absoluta (nᵢ)", caption=fuente_graficas) +
  tema_barras

5.3 Gráfica N° 3 — Frecuencia relativa (hᵢ) local

ggplot2::ggplot(tabla_graf, ggplot2::aes(x=intervalo, y=hi_unit, fill=intervalo)) +
  ggplot2::geom_col(width=.72, color="#244861", linewidth=.36) +
  ggplot2::geom_text(ggplot2::aes(label=sprintf("%.2f%%", hi_perc)), vjust=-.48,
                     size=4.3, fontface="bold", color="#15364C") +
  ggplot2::scale_fill_manual(values=colores) +
  ggplot2::scale_y_continuous(limits=c(0, limite_hi_local), labels=etiqueta_pct,
                              expand=ggplot2::expansion(mult=c(0,0))) +
  ggplot2::coord_cartesian(clip="off") +
  ggplot2::labs(title="Gráfica N° 3: Frecuencia relativa (hᵢ) local",
                x="Profundidad medida (ft)", y="Frecuencia relativa (%)", caption=fuente_graficas) +
  tema_barras

5.4 Gráfica N° 4 — Frecuencia relativa (hᵢ) global

ggplot2::ggplot(tabla_graf, ggplot2::aes(x=intervalo, y=hi_unit)) +
  ggplot2::geom_col(fill=color_barras, color="#244861", width=.72, linewidth=.36) +
  ggplot2::geom_text(ggplot2::aes(label=sprintf("%.2f%%", hi_perc)), vjust=-.48,
                     size=4.3, fontface="bold", color="#15364C") +
  ggplot2::scale_y_continuous(limits=c(0, limite_hi_global), breaks=seq(0, 1, by=.2),
                              labels=etiqueta_pct, expand=ggplot2::expansion(mult=c(0,0))) +
  ggplot2::coord_cartesian(clip="off") +
  ggplot2::labs(title="Gráfica N° 4: Frecuencia relativa (hᵢ) global",
                x="Profundidad medida (ft)", y="Frecuencia relativa (%)", caption=fuente_graficas) +
  tema_barras

5.5 Gráfica N° 5 — Diagrama de caja

col_grid <- "#DDE6ED"
eje_x <- pretty(Variable, n=8)
par(mar=c(7, 5, 4, 2))
plot(NULL, xlim=range(eje_x), ylim=c(0.4, 1.6), axes=FALSE, xlab="", ylab="",
     main="Gráfica N° 5: Diagrama de caja de la profundidad medida")
abline(v=eje_x, col=col_grid, lty="dotted")                    # cuadrícula detrás de la caja
boxplot(Variable, horizontal=TRUE, at=1, add=TRUE, axes=FALSE, col=color_barras,
        border="#15364C", medlwd=3, outline=TRUE, outcol=color_outlier,
        boxwex=0.5, frame.plot=FALSE)
axis(1, at=eje_x, labels=fmt_entero(eje_x), las=2, cex.axis=0.9)
mtext("Profundidad medida (ft)", side=1, line=5.5)

5.6 Gráfica N° 6 — Ojivas de Nᵢ (ascendente y descendente)

ojiva_ni <- data.frame(
  x    = c(TDF_Enteros$Ls, TDF_Enteros$Li),
  y    = c(TDF_Enteros$Ni_asc, TDF_Enteros$Ni_desc),
  tipo = rep(c("Ascendente", "Descendente"), each=K_real)
)

ggplot2::ggplot(ojiva_ni, ggplot2::aes(x=x, y=y, color=tipo, group=tipo)) +
  ggplot2::geom_line(linewidth=1.2) +
  ggplot2::geom_point(size=2.8) +
  ggplot2::scale_color_manual(values=c(Ascendente=color_ojiva1, Descendente=color_ojiva2)) +
  ggplot2::scale_x_continuous(labels=fmt_entero) +
  ggplot2::scale_y_continuous(labels=fmt_entero, limits=c(0, N * 1.05),
                              expand=ggplot2::expansion(mult=c(0, 0))) +
  ggplot2::labs(title="Gráfica N° 6: Ojivas de frecuencia absoluta acumulada (Nᵢ)",
                x="Profundidad medida (ft)", y="Frecuencia absoluta acumulada (Nᵢ)", color=NULL,
                caption=fuente_graficas) +
  tema_barras +
  ggplot2::theme(legend.position="bottom",
                 legend.text=ggplot2::element_text(size=13),
                 axis.text.x=ggplot2::element_text(angle=0, hjust=.5),
                 panel.grid.major.x=ggplot2::element_line(color="#DDE6ED", linewidth=.35))

5.7 Gráfica N° 7 — Ojivas de Hᵢ (ascendente y descendente)

ojiva_hi <- data.frame(
  x    = c(TDF_Enteros$Ls, TDF_Enteros$Li),
  y    = c(TDF_Enteros$Hi_asc_perc, TDF_Enteros$Hi_desc_perc),
  tipo = rep(c("Ascendente", "Descendente"), each=K_real)
)

ggplot2::ggplot(ojiva_hi, ggplot2::aes(x=x, y=y, color=tipo, group=tipo)) +
  ggplot2::geom_line(linewidth=1.2) +
  ggplot2::geom_point(size=2.8) +
  ggplot2::scale_color_manual(values=c(Ascendente=color_ojiva1, Descendente=color_ojiva2)) +
  ggplot2::scale_x_continuous(labels=fmt_entero) +
  ggplot2::scale_y_continuous(labels=function(x) paste0(x, "%"), limits=c(0, 105),
                              expand=ggplot2::expansion(mult=c(0, 0))) +
  ggplot2::labs(title="Gráfica N° 7: Ojivas de frecuencia relativa acumulada (Hᵢ)",
                x="Profundidad medida (ft)", y="Frecuencia acumulada (%)", color=NULL,
                caption=fuente_graficas) +
  tema_barras +
  ggplot2::theme(legend.position="bottom",
                 legend.text=ggplot2::element_text(size=13),
                 axis.text.x=ggplot2::element_text(angle=0, hjust=.5),
                 panel.grid.major.x=ggplot2::element_line(color="#DDE6ED", linewidth=.35))

6 Tabla de Indicadores

Profundidad medida es cuantitativa continua de escala de razón (sección 3): se calculan tendencia central, dispersión, forma y valores atípicos.

media    <- mean(Variable)
mediana  <- median(Variable)
moda_val <- TDF_Enteros$MC[which.max(TDF_Enteros$ni)]   # marca de clase de la clase modal
varianza <- var(Variable)
sd_val   <- sd(Variable)
CV       <- (sd_val / abs(media)) * 100

asim <- e1071::skewness(Variable, type=2)
kurt <- e1071::kurtosis(Variable)                       # curtosis en exceso (normal = 0)

Q1 <- quantile(Variable, 0.25); Q3 <- quantile(Variable, 0.75); IQR_val <- Q3 - Q1
outliers_data <- Variable[Variable < (Q1 - 1.5*IQR_val) | Variable > (Q3 + 1.5*IQR_val)]
num_out <- length(outliers_data)
out_txt <- if (num_out > 0) {
  paste0(fmt_entero(num_out), " [", fmt_num(min(outliers_data), 0), "; ", fmt_num(max(outliers_data), 0), "]")
} else "0 [Sin outliers]"
ind <- data.frame(
  "Variable"="Profundidad medida (ft)",
  "Rango"=paste0("[", fmt_num(min(Variable),0), "; ", fmt_num(max(Variable),0), "]"),
  "Media (X̄)"=fmt_num(media, 2), "Mediana (Me)"=fmt_num(mediana, 2), "Moda (Mo)"=fmt_num(moda_val, 2),
  "Varianza (S²)"=fmt_num(varianza, 2), "Desv. Est. (S)"=fmt_num(sd_val, 2),
  "C.V. (%)"=fmt_num(CV, 2),
  "Asimetría (As)"=fmt_num(asim, 4), "Curtosis (K)"=fmt_num(kurt, 4),
  "Outliers [Intervalo]"=out_txt, check.names=FALSE
)
k <- knitr::kable(ind, format="html", escape=TRUE, align=c("l", rep("c", 10))) |>
  kableExtra::kable_styling(bootstrap_options=c("striped","condensed"),
                           full_width=TRUE, position="center") |>
  kableExtra::add_header_above(c("Variable"=2, "Tendencia central"=3,
    "Dispersión"=3, "Forma"=2, "Valores atípicos"=1), bold=TRUE, background="#dddfe2") |>
  kableExtra::row_spec(0, bold=TRUE, background="#f1f2f4")
cat('<div class="cuadro indicadores">',
    '<div class="cuadro-titulo">Cuadro N° 2: Indicadores estadísticos de Profundidad medida (ft), Nueva York, 1860 - 2026</div>',
    as.character(k),
    '<p class="cuadro-nota"><strong>Registros válidos (N):</strong> ', fmt_entero(N),
    ' &nbsp; | &nbsp; <strong>Clases (k):</strong> ', K_real,
    ' &nbsp; | &nbsp; <strong>Amplitud:</strong> ', Amplitud_int, ' pies',
    ' &nbsp; | &nbsp; <strong>Q1:</strong> ', fmt_num(Q1,0),
    ' &nbsp; | &nbsp; <strong>Q3:</strong> ', fmt_num(Q3,0), '.</p>',
    '<p class="cuadro-nota">La moda se calcula como la marca de clase del intervalo de mayor frecuencia. La curtosis se expresa en exceso respecto a la normal (K = 0).</p>',
    '<p class="cuadro-fuente">Fuente: Oil, Gas &amp; Other Regulated Wells: Beginning 1860.</p></div>', sep="")
Cuadro N° 2: Indicadores estadísticos de Profundidad medida (ft), Nueva York, 1860 - 2026
Variable
Tendencia central
Dispersión
Forma
Valores atípicos
Variable Rango Media (X̄) Mediana (Me) Moda (Mo) Varianza (S²) Desv. Est. (S) C.V. (%) Asimetría (As) Curtosis (K) Outliers [Intervalo]
Profundidad medida (ft) [0; 15921] 1449.79 1255.00 500.00 2467071.17 1570.69 108.34 2.2581 9.8647 1.015 [4869; 15921]

Registros válidos (N): 47.496   |   Clases (k): 16   |   Amplitud: 1000 pies   |   Q1: 0   |   Q3: 1947.

La moda se calcula como la marca de clase del intervalo de mayor frecuencia. La curtosis se expresa en exceso respecto a la normal (K = 0).

Fuente: Oil, Gas & Other Regulated Wells: Beginning 1860.

7 Conclusión

Los valores de la profundidad medida fluctúan entre 0 y 15921 pies y giran en torno a 1255.00 pies (mediana), con una desviación estándar de 1570.69, con valores atípicos (1.015 en total: entre 4869 y 15921 pies), siendo un conjunto de datos heterogéneo (C.V. = 108.34%), cuyos valores se agrupan fuertemente en la parte baja de la profundidad medida (98.50% de los pozos). Por lo anterior, el comportamiento es beneficioso, ya que refleja una concentración de los valores en la parte baja de la profundidad medida.

Autor: Estalin Echeverría | Grupo 5 | Análisis Estadístico — Oil, Gas & Other Regulated Wells - NY State