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_elevacion]]))
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)
if (N == 0L) stop("No hay registros válidos de Elevation.")

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

cat("Variable analizada: Elevation, ft | Unidad: pies (ft s.n.m.)\n")
## Variable analizada: Elevation, ft | Unidad: pies (ft s.n.m.)
cat("Observaciones útiles (N):", fmt_entero(N), "| Nulos omitidos:", fmt_entero(n_nulos), "\n")
## Observaciones útiles (N): 25.612 | Nulos omitidos: 21.889
cat("Mínimo:", fmt_num(Minimo_real, 0), "| Máximo:", fmt_num(Maximo_real, 0), "pies\n")
## Mínimo: 3 | Máximo: 3500 pies

3 Identificación de la Variable

Escala: la elevación es cuantitativa continua de escala de intervalo (el 0 = nivel del mar es una referencia convencional).

VARIABLE TIPO ESCALA DE MEDICIÓN UNIDAD DE MEDIDA UNIDAD DE ANÁLISIS REGISTROS VÁLIDOS (N)
ELEVATION (Elevación, ft) Cuantitativa continua Intervalo Pies (ft) Pozo regulado 25.612

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): 18
cat("Amplitud de clase:", Amplitud_int, "pies\n")
## Amplitud de clase: 200 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 elevación (pies), 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 elevación (pies), Nueva York, 1860 - 2026
LÍM. INF (ft) LÍM. SUP (ft) MARCA DE CLASE (xᵢ) nᵢ hᵢ hᵢ (%) Nᵢ (↑) Nᵢ (↓) Hᵢ (% ↑) Hᵢ (% ↓)
0 200 100.0 288 0.0112 1.12 288 25.612 1.12 100.00
200 400 300.0 212 0.0083 0.83 500 25.324 1.95 98.88
400 600 500.0 1.227 0.0479 4.79 1.727 25.112 6.74 98.05
600 800 700.0 2.432 0.0950 9.50 4.159 23.885 16.24 93.26
800 1000 900.0 2.235 0.0873 8.73 6.394 21.453 24.96 83.76
1000 1200 1100.0 1.920 0.0750 7.50 8.314 19.218 32.46 75.04
1200 1400 1300.0 2.706 0.1057 10.57 11.020 17.298 43.03 67.54
1400 1600 1500.0 4.014 0.1567 15.67 15.034 14.592 58.70 56.97
1600 1800 1700.0 3.594 0.1403 14.03 18.628 10.578 72.73 41.30
1800 2000 1900.0 2.259 0.0882 8.82 20.887 6.984 81.55 27.27
2000 2200 2100.0 2.787 0.1088 10.88 23.674 4.725 92.43 18.45
2200 2400 2300.0 1.868 0.0729 7.29 25.542 1.938 99.73 7.57
2400 2600 2500.0 61 0.0024 0.24 25.603 70 99.96 0.27
2600 2800 2700.0 6 0.0002 0.02 25.609 9 99.99 0.04
2800 3000 2900.0 2 0.0001 0.01 25.611 3 100.00 0.01
3000 3200 3100.0 0 0.0000 0.00 25.611 1 100.00 0.00
3200 3400 3300.0 0 0.0000 0.00 25.611 1 100.00 0.00
3400 3600 3500.0 1 0.0000 0.00 25.612 1 100.00 0.00
TOTAL 25.612 1.0000 100.00

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

Interpretación: el intervalo de elevación con mayor concentración de pozos es [1400 – 1600) pies, con 4.014 pozos (15.67% de los 25.612 registros válidos). Hasta los 1600 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="Elevación (ft s.n.m.)", 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="Elevación (ft s.n.m.)", 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="Elevación (ft s.n.m.)", 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="Elevación (ft s.n.m.)", 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 elevación")
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("Elevación (ft s.n.m.)", 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="Elevación (ft s.n.m.)", 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="Elevación (ft s.n.m.)", 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

Elevación es cuantitativa continua de escala de intervalo (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"="Elevación (ft s.n.m.)",
  "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 Elevación (ft s.n.m.), 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 Elevación (ft s.n.m.), 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]
Elevación (ft s.n.m.) [3; 3500] 1433.39 1495.00 1500.00 291066.87 539.51 37.64 -0.2744 -0.7313 1 [3500; 3500]

Registros válidos (N): 25.612   |   Clases (k): 18   |   Amplitud: 200 pies   |   Q1: 1000   |   Q3: 1840.

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 elevación fluctúan entre 3 y 3500 pies y giran en torno a 1433.39 pies (media), con una desviación estándar de 539.51, con 1 valor atípico (3500 pies), siendo un conjunto de datos heterogéneo (C.V. = 37.64%), cuyos valores se agrupan medianamente en la parte media de la elevación (67.67% de los pozos). Por lo anterior, el comportamiento es beneficioso, ya que refleja una concentración de los valores en la parte media de la elevación.

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