datos_originales <- readr::read_delim(ruta, delim=delimitador, trim_ws=TRUE, show_col_types=FALSE, name_repair="minimal")
## Carga exitosa: 47.501 registros.
# La limpieza es únicamente para el análisis: el archivo CSV no se modifica.
seccion_limpia <- datos_originales |>
dplyr::transmute(Seccion=stringr::str_squish(as.character(.data[[columna_seccion]]))) |>
dplyr::filter(!is.na(Seccion), Seccion != "",
!toupper(Seccion) %in% c("NA", "N/A", "NULL"))
N <- nrow(seccion_limpia)
if (N == 0L) stop("No se encontraron secciones válidas en QUAD_SECTION.")
k_secciones <- dplyr::n_distinct(seccion_limpia$Seccion)
cat("Registros válidos:", fmt_entero(N),
" | Secciones distintas:", fmt_entero(k_secciones), "\n")
## Registros válidos: 46.633 | Secciones distintas: 9
| VARIABLE | TIPO | ESCALA DE MEDICIÓN | UNIDAD DE ANÁLISIS | CATEGORÍAS (k) | REGISTROS VÁLIDOS (N) |
|---|---|---|---|---|---|
| QUAD_SECTION (Sección de la zona cartográfica) | Cualitativa nominal | Nominal | Pozo regulado | 9 | 46.633 |
cat(crear_cuadro(tabla_frecuencias, 1,
"Distribución de frecuencias de los pozos regulados según la sección de la zona cartográfica, Nueva York, 1860 - 2026",
desplazamiento=(k_secciones > 15L)))
| SECCIÓN DE LA ZONA CARTOGRÁFICA | FRECUENCIA ABSOLUTA (nᵢ) | FRECUENCIA RELATIVA (hᵢ) | FRECUENCIA RELATIVA PORCENTUAL (%) |
|---|---|---|---|
| I | 6.102 | 0.1309 | 13.09% |
| A | 3.201 | 0.0686 | 6.86% |
| F | 4.938 | 0.1059 | 10.59% |
| E | 6.189 | 0.1327 | 13.27% |
| C | 3.292 | 0.0706 | 7.06% |
| D | 5.790 | 0.1242 | 12.42% |
| H | 5.556 | 0.1191 | 11.91% |
| G | 6.731 | 0.1443 | 14.43% |
| B | 4.834 | 0.1037 | 10.37% |
| TOTAL GENERAL | 46.633 | 1.0000 | 100.00% |
Fuente: Oil, Gas & Other Regulated Wells: Beginning 1860.
Interpretación: la sección con mayor frecuencia es G, con 6.731 pozos (14.43% del total). La frecuencia mínima es de 3.201 pozo(s) y corresponde a 1 secciones.
# La segunda TDF solo se muestra cuando hay más de diez categorías.
# Si existen diez o menos secciones, la primera TDF es suficiente.
if (k_secciones > 10L) {
cat("## Top 10 de categorías con mayor frecuencia absoluta {-}\n\n")
cat("El Cuadro N° 2 presenta las 10 secciones más frecuentes ",
"ordenadas de mayor a menor y agrupa las restantes en Otras secciones ",
"(siempre al final), conservando los ",
fmt_entero(N), " registros válidos (",
sprintf("%.2f%%", pct_top10), " en el Top 10).\n\n", sep="")
cat(crear_cuadro(tabla_resumen, 2,
"Distribución de frecuencias de los pozos regulados: 10 secciones más frecuentes y Otras, Nueva York, 1860 - 2026"))
}
ggplot2::ggplot(tabla_local, ggplot2::aes(x=Seccion,y=ni,fill=Seccion)) +
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_secciones +
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="Sección cartográfica",y="Frecuencia absoluta (nᵢ)",caption=fuente_graficas) +
tema_barras
ggplot2::ggplot(tabla_global, ggplot2::aes(x=Seccion,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_secciones +
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="Sección cartográfica",y="Frecuencia absoluta (nᵢ)",caption=fuente_graficas) +
tema_barras
ggplot2::ggplot(tabla_local, ggplot2::aes(x=Seccion,y=hi,fill=Seccion)) +
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_secciones +
ggplot2::scale_y_continuous(limits=c(0,limite_hi_local),labels=etiqueta_pct,
expand=ggplot2::expansion(mult=c(0,0))) +
ggplot2::labs(title="Gráfica N° 3: Frecuencia relativa (hᵢ) local",
x="Sección cartográfica",y="Frecuencia relativa (%)",caption=fuente_graficas) +
tema_barras
ggplot2::ggplot(tabla_global, ggplot2::aes(x=Seccion,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_secciones +
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::labs(title="Gráfica N° 4: Frecuencia relativa (hᵢ) global",
x="Sección cartográfica",y="Frecuencia relativa (%)",caption=fuente_graficas) +
tema_barras
leyenda <- paste0(stringr::str_wrap(as.character(tabla_local$Seccion),width=23),
" — ",sprintf("%.2f%%",tabla_local$porcentaje))
ggplot2::ggplot(tabla_local,ggplot2::aes(x=1,y=ni,fill=Seccion)) +
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 la sección de la zona cartográfica",
fill="Sección — 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) |
|---|---|---|---|---|---|---|---|---|
| QUAD_SECTION (Sección de la zona cartográfica) | N/A | N/A | G | N/A | N/A | N/A | N/A | N/A |
N/A: No aplicable a una variable cualitativa nominal.
Registros válidos (N): 46.633 | Categorías: 9 | Frecuencia modal: 6.731 | Porcentaje modal: 14.43%.
Fuente: Oil, Gas & Other Regulated Wells: Beginning 1860.
La variable QUAD_SECTION (Sección de la zona cartográfica) es cualitativa nominal y presenta 9 categorías en 46.633 registros válidos. La moda corresponde a G, con una frecuencia de 6.731 pozos (14.43% del total), lo que evidencia una concentración de los registros en determinadas secciones de las zonas cartográficas del estado de Nueva York.
Autor: Jennifer Cordones | Análisis Estadístico — Oil, Gas & Other Regulated Wells - NY State