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_dd]]))
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 Depth Fee.")

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

cat("Variable analizada: Depth Fee | Unidad: dólares (USD)\n")
## Variable analizada: Depth Fee | Unidad: dólares (USD)
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: 35.744
cat("Mínimo:", fmt_num(Minimo_real, 0), "| Máximo:", fmt_num(Maximo_real, 0), "USD\n")
## Mínimo: 0 | Máximo: 10900 USD

3 Identificación de la Variable

Escala: la tarifa por profundidad es cuantitativa continua de escala de razón (0 USD indica ausencia de cobro). El conjunto incluye 35.744 pozos con valor 0 USD (75.26%), que se mantienen en el análisis.

VARIABLE TIPO ESCALA DE MEDICIÓN UNIDAD DE MEDIDA UNIDAD DE ANÁLISIS REGISTROS VÁLIDOS (N)
DEPTH FEE (Tarifa por profundidad, USD) Cuantitativa continua Razón Dólares (USD) 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): 11
cat("Amplitud de clase:", Amplitud_int, "USD\n")
## Amplitud de clase: 1000 USD
tabla_final <- data.frame(
  "LÍM. INF (USD)"=fmt_num(TDF_Enteros$Li, 0),
  "LÍM. SUP (USD)"=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 (USD)"="TOTAL", "LÍM. SUP (USD)"="", "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 tarifa por profundidad (USD), 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 tarifa por profundidad (USD), Nueva York, 1860 - 2026
LÍM. INF (USD) LÍM. SUP (USD) MARCA DE CLASE (xᵢ) nᵢ hᵢ hᵢ (%) Nᵢ (↑) Nᵢ (↓) Hᵢ (% ↑) Hᵢ (% ↓)
0 1000 500.0 43.539 0.9167 91.67 43.539 47.496 91.67 100.00
1000 2000 1500.0 3.381 0.0712 7.12 46.920 3.957 98.79 8.33
2000 3000 2500.0 336 0.0071 0.71 47.256 576 99.49 1.21
3000 4000 3500.0 111 0.0023 0.23 47.367 240 99.73 0.51
4000 5000 4500.0 85 0.0018 0.18 47.452 129 99.91 0.27
5000 6000 5500.0 40 0.0008 0.08 47.492 44 99.99 0.09
6000 7000 6500.0 3 0.0001 0.01 47.495 4 100.00 0.01
7000 8000 7500.0 0 0.0000 0.00 47.495 1 100.00 0.00
8000 9000 8500.0 0 0.0000 0.00 47.495 1 100.00 0.00
9000 10000 9500.0 0 0.0000 0.00 47.495 1 100.00 0.00
10000 11000 10500.0 1 0.0000 0.00 47.496 1 100.00 0.00
TOTAL 47.496 1.0000 100.00

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

Interpretación: el intervalo de monto con mayor concentración de pozos es [0 – 1000) USD, con 43.539 pozos (91.67% de los 47.496 registros válidos). Hasta los 1000 USD 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="Tarifa por profundidad (USD)", 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="Tarifa por profundidad (USD)", 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="Tarifa por profundidad (USD)", 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="Tarifa por profundidad (USD)", 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 tarifa por profundidad")
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("Tarifa por profundidad (USD)", 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="Tarifa por profundidad (USD)", 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="Tarifa por profundidad (USD)", 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

Tarifa por profundidad 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"="Tarifa por profundidad (USD)",
  "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 Tarifa por profundidad (USD), 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, ' USD',
    ' &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 Tarifa por profundidad (USD), 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]
Tarifa por profundidad (USD) [0; 10900] 230.06 0.00 500.00 269040.94 518.69 225.46 3.9405 26.1299 11.752 [90; 10900]

Registros válidos (N): 47.496   |   Clases (k): 11   |   Amplitud: 1000 USD   |   Q1: 0   |   Q3: 0.

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 tarifa por profundidad fluctúan entre 0 y 10900 USD y giran en torno a 0.00 USD (mediana), con una desviación estándar de 518.69, con valores atípicos (11.752 en total: entre 90 y 10900 USD), siendo un conjunto de datos heterogéneo (C.V. = 225.46%), cuyos valores se agrupan fuertemente en la parte baja de la tarifa por profundidad (99.65% 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 tarifa por profundidad.

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