ruta <- "C:/Users/cordo/OneDrive/Desktop/ESTADISITCA/Oil__Gas____Other_Regulated_Wells__Beginning_1860.csv"
datos_originales <- readr::read_delim(
ruta, delim=";", trim_ws=TRUE, show_col_types=FALSE,
name_repair="minimal", locale=readr::locale(encoding="UTF-8")
)
cat("Carga exitosa:", fmt_entero(nrow(datos_originales)), "registros.\n")
## Carga exitosa: 47.407 registros.
county_limpio <- datos_originales |>
dplyr::transmute(Condado=stringr::str_squish(as.character(.data[[columna_county]]))) |>
dplyr::filter(!is.na(Condado), Condado != "", !toupper(Condado) %in% c("NA", "N/A", "NULL"))
set.seed(2026)
county_limpio$Condado <- factor(county_limpio$Condado,
levels=sample(unique(county_limpio$Condado)))
N <- nrow(county_limpio)
if (length(levels(county_limpio$Condado)) != 56L) {
stop("El archivo contiene ", length(levels(county_limpio$Condado)),
" categorías válidas de County y se esperaban 56. ",
"Comprueba la ruta y que no hayas filtrado el CSV.")
}
cat("Registros válidos:", fmt_entero(N),
" | Condados distintos:", nlevels(county_limpio$Condado), "\n")
## Registros válidos: 47.360 | Condados distintos: 56
La variable County (Condado) es cualitativa nominal: identifica condados sin establecer un orden jerárquico entre ellos.
tipo_variable <- "Cualitativa nominal"
El Cuadro N° 1 contiene los 56 condados y la fila Total (57 filas). Desplázate dentro de la tabla para verlos todos.
cat(crear_cuadro(tabla_frecuencias, 1,
"Distribución de frecuencias de los pozos regulados según el Condado en el estado de Nueva York, 1860 - Actualidad",
desplazamiento=TRUE))
| CONDADO | FRECUENCIA ABSOLUTA (nᵢ) | FRECUENCIA RELATIVA (hᵢ) | FRECUENCIA RELATIVA PORCENTUAL (%) |
|---|---|---|---|
| Schuyler | 438 | 0.0092 | 0.92% |
| Dutchess | 10 | 0.0002 | 0.02% |
| Herkimer | 14 | 0.0003 | 0.03% |
| Jefferson | 13 | 0.0003 | 0.03% |
| Albany | 19 | 0.0004 | 0.04% |
| Oswego | 212 | 0.0045 | 0.45% |
| Schenectady | 2 | 0.0000 | 0.00% |
| Monroe | 32 | 0.0007 | 0.07% |
| Broome | 68 | 0.0014 | 0.14% |
| Yates | 161 | 0.0034 | 0.34% |
| Saratoga | 5 | 0.0001 | 0.01% |
| Cayuga | 491 | 0.0104 | 1.04% |
| Schoharie | 4 | 0.0001 | 0.01% |
| Onondaga | 294 | 0.0062 | 0.62% |
| Genesee | 880 | 0.0186 | 1.86% |
| Chautauqua | 6.367 | 0.1344 | 13.44% |
| St Lawrence | 1 | 0.0000 | 0.00% |
| Wayne | 38 | 0.0008 | 0.08% |
| Erie | 3.483 | 0.0735 | 7.35% |
| Essex | 3 | 0.0001 | 0.01% |
| Orange | 21 | 0.0004 | 0.04% |
| Sullivan | 3 | 0.0001 | 0.01% |
| Otsego | 20 | 0.0004 | 0.04% |
| Wyoming | 1.149 | 0.0243 | 2.43% |
| Clinton | 1 | 0.0000 | 0.00% |
| Delaware | 39 | 0.0008 | 0.08% |
| Bronx | 20 | 0.0004 | 0.04% |
| Statewide | 593 | 0.0125 | 1.25% |
| Warren | 2 | 0.0000 | 0.00% |
| Richmond | 2 | 0.0000 | 0.00% |
| Steuben | 2.067 | 0.0436 | 4.36% |
| Washington | 3 | 0.0001 | 0.01% |
| Tompkins | 110 | 0.0023 | 0.23% |
| Cortland | 30 | 0.0006 | 0.06% |
| Rockland | 7 | 0.0001 | 0.01% |
| Montgomery | 9 | 0.0002 | 0.02% |
| Ontario | 347 | 0.0073 | 0.73% |
| Nassau | 4 | 0.0001 | 0.01% |
| New York | 213 | 0.0045 | 0.45% |
| Chemung | 234 | 0.0049 | 0.49% |
| Tioga | 125 | 0.0026 | 0.26% |
| Ulster | 10 | 0.0002 | 0.02% |
| Orleans | 30 | 0.0006 | 0.06% |
| Niagara | 16 | 0.0003 | 0.03% |
| Livingston | 457 | 0.0096 | 0.96% |
| Fulton | 5 | 0.0001 | 0.01% |
| Seneca | 456 | 0.0096 | 0.96% |
| Allegany | 16.397 | 0.3462 | 34.62% |
| Queens | 12 | 0.0003 | 0.03% |
| Greene | 3 | 0.0001 | 0.01% |
| Madison | 144 | 0.0030 | 0.30% |
| Oneida | 72 | 0.0015 | 0.15% |
| Chenango | 201 | 0.0042 | 0.42% |
| Westchester | 61 | 0.0013 | 0.13% |
| Lewis | 11 | 0.0002 | 0.02% |
| Cattaraugus | 11.951 | 0.2523 | 25.23% |
| Total | 47.360 | 1.0000 | 100.00% |
Fuente: Oil, Gas & Other Regulated Wells: Beginning 1860.
La tabla resume los 10 condados más frecuentes y agrupa los demás en Otros, conservando el total de 47.360 registros válidos.
cat(crear_cuadro(tabla_resumen, 2,
"Distribución de frecuencias de los pozos regulados: 10 condados más frecuentes y Otros, Nueva York, 1860 - Actualidad"))
| CONDADO | FRECUENCIA ABSOLUTA (nᵢ) | FRECUENCIA RELATIVA (hᵢ) | FRECUENCIA RELATIVA PORCENTUAL (%) |
|---|---|---|---|
| Allegany | 16.397 | 0.3462 | 34.62% |
| Cattaraugus | 11.951 | 0.2523 | 25.23% |
| Chautauqua | 6.367 | 0.1344 | 13.44% |
| Erie | 3.483 | 0.0735 | 7.35% |
| Steuben | 2.067 | 0.0436 | 4.36% |
| Wyoming | 1.149 | 0.0243 | 2.43% |
| Genesee | 880 | 0.0186 | 1.86% |
| Statewide | 593 | 0.0125 | 1.25% |
| Cayuga | 491 | 0.0104 | 1.04% |
| Livingston | 457 | 0.0096 | 0.96% |
| Otros | 3.525 | 0.0744 | 7.44% |
| Total | 47.360 | 1.0000 | 100.00% |
Fuente: Oil, Gas & Other Regulated Wells: Beginning 1860.
Las gráficas representan el Top 10 y Otros; la tabla principal conserva todas las categorías.
ggplot2::ggplot(tabla_plot, ggplot2::aes(Condado, ni, fill=Condado)) +
ggplot2::geom_col(width=.72) +
ggplot2::geom_text(ggplot2::aes(label=fmt_entero(ni)),vjust=-.4,size=3) +
ggplot2::scale_fill_manual(values=colores) +
ggplot2::scale_y_continuous(expand=ggplot2::expansion(mult=c(0,.14))) +
ggplot2::labs(title="Gráfica N° 1: Frecuencia absoluta por condado",x="Condado",y="Frecuencia absoluta (nᵢ)") + tema_barras
ggplot2::ggplot(tabla_plot, ggplot2::aes(Condado, porcentaje, fill=Condado)) +
ggplot2::geom_col(width=.72) +
ggplot2::geom_text(ggplot2::aes(label=sprintf("%.2f%%",porcentaje)),vjust=-.4,size=3) +
ggplot2::scale_fill_manual(values=colores) +
ggplot2::scale_y_continuous(expand=ggplot2::expansion(mult=c(0,.14))) +
ggplot2::labs(title="Gráfica N° 2: Frecuencia porcentual por condado",x="Condado",y="Frecuencia relativa porcentual (%)") + tema_barras
leyenda <- paste0(as.character(tabla_plot$Condado), " — ", sprintf("%.2f%%",tabla_plot$porcentaje))
ggplot2::ggplot(tabla_plot,ggplot2::aes(x=1,y=ni,fill=Condado)) +
ggplot2::geom_col(width=1,color="white",linewidth=.35) +
ggplot2::coord_polar(theta="y",start=0) +
ggplot2::scale_fill_manual(values=colores,labels=leyenda) +
ggplot2::labs(title="Gráfica N° 3: Distribución porcentual por condado",fill="Condado — porcentaje") +
ggplot2::theme_void() + ggplot2::theme(plot.title=ggplot2::element_text(hjust=.5,face="bold"),legend.position="right")
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) |
|---|---|---|---|---|---|---|---|---|
| County (Condado) | N/A | N/A | Allegany | N/A | N/A | N/A | N/A | N/A |
N/A: No aplicable a una variable cualitativa nominal.
Registros válidos (N): 47.360 | Categorías: 56 | Frecuencia modal: 16.397 | Porcentaje modal: 34.62%.
Fuente: Oil, Gas & Other Regulated Wells: Beginning 1860.
La variable County (Condado) es cualitativa nominal policotómica y presenta 56 categorías en 47.360 registros válidos. La moda corresponde a Allegany, con una frecuencia de 16.397 pozos (34.62% del total), lo que evidencia una concentración de los registros en determinados condados del estado de Nueva York.
Autor: Jennifer Cordones | Análisis Estadístico — Oil, Gas & Other Regulated Wells - NY State