1. Configuración y Carga de Datos

datos_originales <- readr::read_csv2(
  "C:/Users/cordo/OneDrive/Desktop/ESTADISITCA/Oil__Gas____Other_Regulated_Wells__Beginning_1860.csv",
  locale = readr::locale(encoding = "Latin1")
)

head(datos_originales, 5)
## # A tibble: 5 × 55
##   `API Well Number` `County Code` `API Hole Number` Sidetrack Completion
##               <dbl>         <dbl>             <dbl>     <dbl>      <dbl>
## 1           3.10e15             3              2670         0          0
## 2           3.10e15             3              4599         0          0
## 3           3.10e15             3              4842         0          0
## 4           3.10e15             3              5419         0          0
## 5           3.11e15           101             26525         0          0
## # ℹ 50 more variables: `Well Name` <chr>, `Company Name` <chr>,
## #   `Operator Number` <dbl>, `Well Type` <chr>, `Map Symbol` <chr>,
## #   `Well Status` <chr>, `Status Date` <chr>, `Permit Application Date` <chr>,
## #   `Permit Issued Date` <chr>, `Date Spudded` <chr>,
## #   `Date of Total Depth` <chr>, `Completion Decade` <chr>,
## #   `Completion Year` <chr>, `Completion Month` <chr>, `Completion Day` <chr>,
## #   `Date Well Plugged` <chr>, `Date Well Confidentiality Ends` <chr>, …

2. Extracción y Limpieza de la Variable

Extraemos la columna Quad Section, que representa las secciones de cuadrante, y procedemos a eliminar los registros nulos (NA) o vacíos para evitar distorsiones en las frecuencias.

datos_limpios <- datos_originales %>%
  select(`Quad Section`) %>%
  filter(!is.na(`Quad Section`) & `Quad Section` != "" & `Quad Section` != " ") %>%
  mutate(`Quad Section` = str_to_title(trimws(`Quad Section`))) 

head(datos_limpios, 10)
## # A tibble: 10 × 1
##    `Quad Section`
##    <chr>         
##  1 F             
##  2 F             
##  3 D             
##  4 A             
##  5 D             
##  6 A             
##  7 A             
##  8 B             
##  9 G             
## 10 A

3. Identificación de la Variable

  • Nombre de la Variable: QUAD SECTION (Sección de cuadrante de ubicación del pozo)
  • Tipo de Variable: Cualitativa Nominal (Categorías sin orden de jerarquía intrínseco).

4. Tabla de Distribución de Frecuencias (TDF)

Dado que la variable tiene una alta cantidad de categorías, agruparemos las secciones con menores frecuencias bajo la etiqueta “Otros”, manteniendo las 10 localidades más frecuentes de forma individual para optimizar la claridad analítica.

# TDF
tdf_quad_section <- datos_limpios %>%
  group_by(`Quad Section`) %>%
  summarise(Fi = n(), .groups = 'drop') %>%
  arrange(desc(Fi)) %>%
  mutate(
    hi = Fi / sum(Fi),
    Pi = hi * 100
  )

total_observaciones <- sum(tdf_quad_section$Fi)

top_sections <- tdf_quad_section %>% slice_max(order_by = Fi, n = 10)
otras_sections <- tdf_quad_section %>% slice(11:n()) %>% 
  summarise(`Quad Section` = "Otros", Fi = sum(Fi), hi = sum(hi), Pi = sum(Pi))

tdf_presentacion <- bind_rows(top_sections, otras_sections) %>%
  mutate(
    `Fi_ac` = cumsum(Fi),
    `hi_ac` = cumsum(hi)
  )

tdf_presentacion %>%
  rename(
    `Sección de Cuadrante (Quad Section)` = `Quad Section`,
    `Frec. Absoluta (Fi)` = Fi,
    `Frec. Relativa (hi)` = hi,
    `Porcentaje (%)` = Pi,
    `Frec. Abs. Acumulada (Fi_ac)` = Fi_ac,
    `Frec. Rel. Acumulada (hi_ac)` = hi_ac
  ) %>%
  kbl(
    caption = "<div style='color:#1D4E73; font-family:\"Lora\", serif; font-weight:bold; font-size:16px; text-align:center; width:100%; display:block;'>TABLA 1. Distribución de Frecuencias de Pozos por Sección de Cuadrante</div>",
    digits = 4, 
    align = "lccccc"
  ) %>%
  kable_styling(
    bootstrap_options = c("hover", "striped"),
    full_width = TRUE,
    position = "center"
  ) %>%
  row_spec(0, 
           background = "#1D4E73", 
           color = "white", 
           bold = TRUE, 
           align = "center",
           extra_css = "padding: 12px !important; font-family: 'Lora', serif; font-size: 14px;"
  ) %>%
  row_spec(1:nrow(tdf_presentacion), 
           extra_css = "padding: 10px !important; font-family: 'Lora', serif; font-size: 14px; border-bottom: 1px solid #7ABDEF !important;"
  ) %>%
  footnote(general = paste("Total de registros históricos válidos procesados:", comma(total_observaciones)))
TABLA 1. Distribución de Frecuencias de Pozos por Sección de Cuadrante
Sección de Cuadrante (Quad Section) Frec. Absoluta (Fi) Frec. Relativa (hi) Porcentaje (%) Frec. Abs. Acumulada (Fi_ac) Frec. Rel. Acumulada (hi_ac)
G 6723 0.1445 14.4522 6723 0.1445
E 6156 0.1323 13.2333 12879 0.2769
I 6093 0.1310 13.0979 18972 0.4078
D 5772 0.1241 12.4078 24744 0.5319
H 5546 0.1192 11.9220 30290 0.6511
F 4933 0.1060 10.6043 35223 0.7572
B 4831 0.1039 10.3850 40054 0.8610
C 3264 0.0702 7.0165 43318 0.9312
A 3201 0.0688 6.8811 46519 1.0000
Otros 3201 0.0688 6.8811 49720 1.0688
Note:
Total de registros históricos válidos procesados: 46,519

5. Representación Gráfica

# Paleta de colores
paleta_azul <- c(
  "#1D4E73", "#2870A4", "#3392D5", "#56A9E2", "#7ABDEF", 
  "#A3D2F7", "#CBE4FA", "#DCEEFC", "#EAF4FD", "#F2F7FB", "#BDC5C8"
)

fuente_unificada <- "Lora"
tamano_titulo    <- 16
tamano_ejes      <- 13
tamano_labels    <- 12

datos_ordenados <- tdf_presentacion %>%
  mutate(`Quad Section` = factor(`Quad Section`, levels = c(setdiff(`Quad Section`, "Otros"), "Otros")))

5.1 Gráfica N°1 — Diagrama de Barras (Frecuencia Absoluta)

ggplot(datos_ordenados, aes(x = `Quad Section`, y = Fi, fill = `Quad Section`)) +
  geom_bar(stat = "identity", color = "#1D4E73", lwd = 0.4, width = 0.72, show.legend = FALSE) +
  geom_text(
    aes(label = comma(Fi)), 
    vjust = -0.5, 
    size = 4.5, 
    fontface = "bold", 
    family = fuente_unificada,
    color = "#1D4E73"
  ) +
  scale_fill_manual(values = paleta_azul) +
  scale_y_continuous(labels = comma, expand = expansion(mult = c(0, 0.12))) +
  labs(
    title = "Gráfica N°1: Frecuencia Absoluta de Pozos por Sección de Cuadrante",
    x = "Secciones de Cuadrante",
    y = "Número Total de Pozos (Fi)"
  ) +
  theme_minimal() +
  theme(
    plot.title = element_text(family = fuente_unificada, size = tamano_titulo, face = "bold", color = "#1D4E73", hjust = 0.5, margin = margin(b = 20)),
    axis.title = element_text(family = fuente_unificada, size = tamano_ejes, face = "bold", color = "#2c1e21"),
    axis.text.x = element_text(family = fuente_unificada, size = tamano_labels, angle = 35, hjust = 1, face = "bold", color = "#4a3b3d"),
    axis.text.y = element_text(family = fuente_unificada, size = tamano_labels, color = "#4a3b3d"),
    panel.grid.major.x = element_blank(),
    panel.grid.minor = element_blank()
  )

5.2 Gráfica N°2 — Diagrama de Barras (Porcentaje)

ggplot(datos_ordenados, aes(x = `Quad Section`, y = Pi, fill = `Quad Section`)) +
  geom_bar(stat = "identity", color = "#1D4E73", lwd = 0.4, width = 0.72, show.legend = FALSE) +
  geom_text(
    aes(label = paste0(round(Pi, 1), "%")), 
    vjust = -0.5, 
    size = 4.5, 
    fontface = "bold", 
    family = fuente_unificada,
    color = "#1D4E73"
  ) +
  scale_fill_manual(values = paleta_azul) +
  scale_y_continuous(limits = c(0, max(datos_ordenados$Pi) * 1.15), labels = function(x) paste0(x, "%")) +
  labs(
    title = "Gráfica N°2: Distribución Porcentual Relativa de Pozos",
    x = "Secciones de Cuadrante",
    y = "Porcentaje de Participación (%)"
  ) +
  theme_minimal() +
  theme(
    plot.title = element_text(family = fuente_unificada, size = tamano_titulo, face = "bold", color = "#1D4E73", hjust = 0.5, margin = margin(b = 20)),
    axis.title = element_text(family = fuente_unificada, size = tamano_ejes, face = "bold", color = "#2c1e21"),
    axis.text.x = element_text(family = fuente_unificada, size = tamano_labels, angle = 35, hjust = 1, face = "bold", color = "#4a3b3d"),
    axis.text.y = element_text(family = fuente_unificada, size = tamano_labels, color = "#4a3b3d"),
    panel.grid.major.x = element_blank(),
    panel.grid.minor = element_blank()
  )

5.3 Gráfica N°3 — Diagrama Circular Estructurado

datos_pie <- datos_ordenados %>%
  arrange(`Quad Section`) %>%
  mutate(
    Section_Etiqueta = paste0(`Quad Section`, " (", round(Pi, 1), "%)"),
    Section_Etiqueta = factor(Section_Etiqueta, levels = Section_Etiqueta),
    label_text = paste0(round(Pi, 1), "%")
  )

ggplot(datos_pie, aes(x = "", y = Pi, fill = Section_Etiqueta)) +
  geom_bar(stat = "identity", width = 1, color = "#ffffff", size = 0.5) +
  coord_polar("y", start = 0) +
  scale_fill_manual(values = paleta_azul, name = "Secciones (Quad Section)") +
  
  geom_text(
    aes(label = ifelse(Pi >= 5, label_text, "")),
    position = position_stack(vjust = 0.5), 
    color = "white", 
    fontface = "bold", 
    family = fuente_unificada, 
    size = 4.5
  ) +
  
  labs(
    title = "Gráfica N°3: Distribución Porcentual Estructurada de Pozos por Sección"
  ) +
  theme_void() +
  theme(
    plot.title = element_text(family = fuente_unificada, size = tamano_titulo, face = "bold", color = "#1D4E73", hjust = 0.5, margin = margin(b = 15)),
    legend.title = element_text(family = fuente_unificada, size = tamano_ejes, face = "bold", color = "#1D4E73"),
    legend.text = element_text(family = fuente_unificada, size = tamano_labels, color = "#2c1e21"),
    legend.position = "right"
  )


6. Tabla de Indicadores

Debido a la naturaleza nominal de la variable QUAD SECTION, se calculan indicadores estadísticos de categorización y concentración en lugar de promedios o desviaciones estándar.

moda_section <- tdf_quad_section$`Quad Section`[1]
moda_frecuencia <- tdf_quad_section$Fi[1]
moda_porcentaje <- tdf_quad_section$Pi[1]
top3_porcentaje <- sum(tdf_quad_section$Pi[1:3])

indicadores <- data.frame(
  Indicador = c(
    "Total de Pozos Válidos Registrados (N)",
    "Número Total de Secciones Registradas (Categorías)",
    "Sección de Máxima Concentración (Moda)",
    "Frecuencia Absoluta de la Moda (Pozos)",
    "Porcentaje de Representación de la Moda (%)",
    "Tasa de Concentración Acumulada Top 3 (%)"
  ),
  Valor = c(
    comma(total_observaciones),
    comma(nrow(tdf_quad_section)),
    moda_section,
    comma(moda_frecuencia),
    paste0(round(moda_porcentaje, 2), "%"),
    paste0(round(top3_porcentaje, 2), "%")
  )
)

indicadores %>%
  kbl(
    caption = "<div style='color:#1D4E73; font-family:\"Lora\", serif; font-weight:bold; font-size:16px; text-align:center; width:100%; display:block;'>TABLA 2. Indicadores Estadísticos de la Variable QUAD SECTION</div>",
    align = "lc"
  ) %>%
  kable_styling(
    bootstrap_options = c("hover", "striped"),
    full_width = TRUE,
    position = "center"
  ) %>%
  row_spec(0, 
           background = "#2870A4", 
           color = "white", 
           bold = TRUE, 
           align = "center",
           extra_css = "padding: 12px !important; font-family: 'Lora', serif; font-size: 14px;"
  ) %>%
  row_spec(1:nrow(indicadores), 
           extra_css = "padding: 12px !important; font-family: 'Lora', serif; font-size: 14px; border-bottom: 1px solid #56A9E2 !important;"
  )
TABLA 2. Indicadores Estadísticos de la Variable QUAD SECTION
Indicador Valor
Total de Pozos Válidos Registrados (N) 46,519
Número Total de Secciones Registradas (Categorías) 9
Sección de Máxima Concentración (Moda) G
Frecuencia Absoluta de la Moda (Pozos) 6,723
Porcentaje de Representación de la Moda (%) 14.45%
Tasa de Concentración Acumulada Top 3 (%) 40.78%

7. Conclusión

Los resultados muestran que la gran mayoría de los pozos se concentran en muy pocas secciones:

  • Sección con mayor cantidad de pozos: La mayor parte de la actividad ocurre en G, que por sí solo representa el 14.5% de todos los registros.
  • Zona central: Si sumamos las 3 secciones con más registros, se acumula el 40.8% del total, lo que confirma que el trabajo fuerte se agrupa en un sector muy pequeño.
  • Resto del territorio: El porcentaje restante está repartido en pequeñas cantidades por muchas otras secciones, agrupadas aquí bajo la etiqueta “Otros”.