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.
desvio_limpio <- datos_originales |>
dplyr::transmute(Desvio=stringr::str_squish(as.character(.data[[columna_sidetrack]]))) |>
dplyr::filter(!is.na(Desvio), Desvio != "",
!toupper(Desvio) %in% c("NA", "N/A", "NULL"))
N <- nrow(desvio_limpio)
if (N == 0L) stop("No se encontraron valores válidos para SIDETRACK.")
k_desvios <- dplyr::n_distinct(desvio_limpio$Desvio)
cat("Registros válidos:", fmt_entero(N),
" | Categorías distintas de Sidetrack:", fmt_entero(k_desvios), "\n")
## Registros válidos: 47.501 | Categorías distintas de Sidetrack: 5
| VARIABLE | TIPO | ESCALA DE MEDICIÓN | UNIDAD DE ANÁLISIS | CATEGORÍAS (k) | REGISTROS VÁLIDOS (N) |
|---|---|---|---|---|---|
| SIDETRACK (Desvío lateral del pozo) | Cualitativa nominal | Nominal | Pozo regulado | 5 | 47.501 |
cat(crear_cuadro(tabla_frecuencias, 1,
"Distribución de frecuencias de los pozos regulados según el desvío lateral del pozo, Nueva York, 1860 - 2026",
desplazamiento=(k_desvios > 6L)))
| DESVÍO LATERAL DEL POZO | FRECUENCIA ABSOLUTA (nᵢ) | FRECUENCIA RELATIVA (hᵢ) | FRECUENCIA RELATIVA PORCENTUAL (%) |
|---|---|---|---|
| 4 | 1 | 0.0000 | 0.00% |
| 0 | 47.268 | 0.9951 | 99.51% |
| 3 | 6 | 0.0001 | 0.01% |
| 1 | 191 | 0.0040 | 0.40% |
| 2 | 35 | 0.0007 | 0.07% |
| TOTAL GENERAL | 47.501 | 1.0000 | 100.00% |
Fuente: Oil, Gas & Other Regulated Wells: Beginning 1860.
Interpretación: la categoría de desvío lateral más frecuente es 0, con 47.268 pozos (99.51% del total). La menor frecuencia observada es de 1 pozos, compartida por 1 categorías.
# Segunda TDF cuando existan más de seis categorías: Top 6 + Otros.
if (k_desvios > 6L) {
cat("## Top 6 de categorías con mayor frecuencia absoluta {-}\n\n")
cat("El Cuadro N° 2 presenta las 6 categorías de desvío lateral más frecuentes, ",
"ordenadas de mayor a menor frecuencia, y agrupa las restantes en ",
"Otros desvíos laterales (al final). Se conservan los ",
fmt_entero(N), " registros válidos; el Top 6 reúne el ",
sprintf("%.2f%%", pct_top6), " del total.\n\n", sep="")
cat(crear_cuadro(tabla_resumen, 2,
"Distribución de frecuencias de los pozos regulados: 6 categorías de desvío lateral más frecuentes y Otros, Nueva York, 1860 - 2026"))
}
ggplot2::ggplot(tabla_local, ggplot2::aes(x=Desvio,y=ni,fill=Desvio)) +
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) +
escala_desvios +
ggplot2::scale_y_continuous(limits=c(0,limite_ni_local),
labels=fmt_entero,
expand=ggplot2::expansion(mult=c(0,0))) +
ggplot2::labs(title="Gráfica N° 1: Frecuencia absoluta (nᵢ) local",
x="Desvío lateral del pozo",y="Frecuencia absoluta (nᵢ)",caption=fuente_graficas) +
tema_barras
ggplot2::ggplot(tabla_global, ggplot2::aes(x=Desvio,y=ni)) +
ggplot2::geom_col(fill="#286492",color="#244861",width=.72,linewidth=.36) +
ggplot2::geom_text(ggplot2::aes(label=fmt_entero(ni)),vjust=-.48,
size=4.5,fontface="bold",color="#15364C") +
escala_desvios +
ggplot2::scale_y_continuous(limits=c(0,limite_ni_global),
labels=fmt_entero,
expand=ggplot2::expansion(mult=c(0,0))) +
ggplot2::labs(title="Gráfica N° 2: Frecuencia absoluta (nᵢ) global",
x="Desvío lateral del pozo",y="Frecuencia absoluta (nᵢ)",caption=fuente_graficas) +
tema_barras
ggplot2::ggplot(tabla_local, ggplot2::aes(x=Desvio,y=hi,fill=Desvio)) +
ggplot2::geom_col(width=.72,color="#244861",linewidth=.36) +
ggplot2::geom_text(ggplot2::aes(label=sprintf("%.2f%%",100*hi)),vjust=-.48,
size=4.3,fontface="bold",color="#15364C") +
ggplot2::scale_fill_manual(values=colores) +
escala_desvios +
ggplot2::scale_y_continuous(limits=c(0,limite_hi_local),labels=etiqueta_pct,
expand=ggplot2::expansion(mult=c(0,.08))) +
ggplot2::labs(title="Gráfica N° 3: Frecuencia relativa (hᵢ) local",
x="Desvío lateral del pozo",y="Frecuencia relativa (%)",caption=fuente_graficas) +
tema_barras
ggplot2::ggplot(tabla_global, ggplot2::aes(x=Desvio,y=hi)) +
ggplot2::geom_col(fill="#286492",color="#244861",width=.72,linewidth=.36) +
ggplot2::geom_text(ggplot2::aes(label=sprintf("%.2f%%",100*hi)),vjust=-.48,
size=4.3,fontface="bold",color="#15364C") +
escala_desvios +
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,.08))) +
ggplot2::labs(title="Gráfica N° 4: Frecuencia relativa (hᵢ) global",
x="Desvío lateral del pozo",y="Frecuencia relativa (%)",caption=fuente_graficas) +
tema_barras
leyenda <- paste0(stringr::str_wrap(as.character(tabla_local$Desvio),width=23),
" — ",sprintf("%.2f%%",tabla_local$porcentaje))
ggplot2::ggplot(tabla_local,ggplot2::aes(x=1,y=ni,fill=Desvio)) +
ggplot2::geom_col(width=1,color="#244861",linewidth=.48) +
ggplot2::coord_polar(theta="y",start=0) +
ggplot2::scale_fill_manual(values=colores,labels=leyenda) +
ggplot2::labs(title="Gráfica N° 5: Distribución porcentual según el desvío lateral del pozo",
fill="Desvío lateral del pozo — porcentaje",caption=fuente_graficas) +
ggplot2::theme_void(base_size=15) +
ggplot2::theme(
plot.title=ggplot2::element_text(hjust=.5,face="bold",size=17,color="#15364C"),
plot.subtitle=ggplot2::element_text(hjust=.5,size=12,color="#49657A",
margin=ggplot2::margin(t=7,b=12)),
legend.position="right",
legend.title=ggplot2::element_text(face="bold",size=13,color="#15364C"),
legend.text=ggplot2::element_text(size=12,color="#253B4B",lineheight=1.05),
legend.key.size=grid::unit(.56,"cm"),
plot.caption=ggplot2::element_text(hjust=0,face="italic",size=10.5,
color="#546775",margin=ggplot2::margin(t=14)),
plot.margin=ggplot2::margin(18,30,25,24)
)
cat(crear_indicadores())
| VARIABLE ANALIZADA | Media (X̄) | Mediana (Me) | Moda (Mo) | Desviación estándar (Sd) | Coeficiente de variación (CV %) | Asimetría (As) | Curtosis (K) | Valores atípicos (Outliers) |
|---|---|---|---|---|---|---|---|---|
| SIDETRACK (Desvío lateral del pozo) | N/A | N/A | 0 | N/A | N/A | N/A | N/A | N/A |
N/A: No aplicable a una variable cualitativa nominal.
Registros válidos (N): 47.501 | Categorías: 5 | Frecuencia modal: 47.268 | Porcentaje modal: 99.51%.
Fuente: Oil, Gas & Other Regulated Wells: Beginning 1860.
La variable SIDETRACK (Desvío lateral del pozo) es cualitativa nominal y presenta 5 categorías en 47.501 registros válidos. La moda corresponde a 0, con una frecuencia de 47.268 pozos (99.51% del total), lo que evidencia una concentración de los registros en determinadas categorías de desvío lateral de los pozos regulados del estado de Nueva York.
Autor: Jennifer Cordones | Análisis Estadístico — Oil, Gas & Other Regulated Wells - NY State