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")
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

datos_limpios <- datos_originales %>%
  select(`Producing Formation`) %>%
  filter(!is.na(`Producing Formation`)) %>%
  mutate(`Producing Formation` = as.character(trimws(`Producing Formation`)))
head(datos_limpios, 10)
## # A tibble: 10 × 1
##    `Producing Formation`
##    <chr>                
##  1 Fulmer Valley        
##  2 Salina               
##  3 Medina               
##  4 Medina               
##  5 Fulmer Valley        
##  6 Fulmer Valley        
##  7 Medina               
##  8 Theresa              
##  9 Fulmer Valley        
## 10 Fulmer Valley

3. Identificación de la Variable

  • Variable: PRODUCING FORMATION (Formación Productora).
  • Tipo: Cualitativa Nominal.
  • Descripción: Unidad geológica o formación específica de donde se extraen los hidrocarburos.

4. Tabla de Distribución de Frecuencias

tdf_base <- datos_limpios %>%
  group_by(`Producing Formation`) %>% 
  summarise(Fi = n(), .groups = 'drop') %>% 
  arrange(desc(Fi))

top_10 <- head(tdf_base, 10)
otros <- data.frame(`Producing Formation` = "Otros", Fi = sum(tdf_base$Fi[11:nrow(tdf_base)]))

tabla_final <- bind_rows(top_10, otros) %>%
  mutate(hi = Fi/sum(Fi), Pi = hi*100, Fi_ac = cumsum(Fi), hi_ac = cumsum(hi))

tabla_final %>%
  rename(`Formación` = `Producing Formation`, `Frec. Abs. (Fi)` = Fi, `Frec. Rel. (hi)` = hi, 
         `Porcentaje (%)` = Pi, `Frec. Abs. Acum. (Fi_ac)` = Fi_ac, `Frec. Rel. Acum. (hi_ac)` = hi_ac) %>%
  kbl(align = "lccccc", escape = FALSE) %>%
  kable_styling(bootstrap_options = c("hover", "striped"), full_width = TRUE) %>%
  row_spec(0, background = "#1D4E73", color = "white", bold = TRUE)
Formación Frec. Abs. (Fi) Producing.Formation Frec. Rel. (hi) Porcentaje (%) Frec. Abs. Acum. (Fi_ac) Frec. Rel. Acum. (hi_ac)
Richburg 8857 NA 0.2688338 26.883385 8857 0.2688338
Medina 8819 NA 0.2676804 26.768045 17676 0.5365143
Chipmunk 2369 NA 0.0719055 7.190554 20045 0.6084198
Bradford 2052 NA 0.0622837 6.228374 22097 0.6707036
Fulmer Valley 1975 NA 0.0599466 5.994658 24072 0.7306502
Glade 749 NA 0.0227342 2.273417 24821 0.7533843
Chipmunk, Bradford 2nd & 3rd 714 NA 0.0216718 2.167183 25535 0.7750562
Queenston 651 NA 0.0197596 1.975961 26186 0.7948158
Scio 645 NA 0.0195775 1.957749 26831 0.8143932
Bradford & Chipmunk 618 NA 0.0187580 1.875797 27449 0.8331512
NA 5497 Otros 0.1668488 16.684878 32946 1.0000000

5. Representación Gráfica

5.1 Gráfica N°1: Frecuencia Absoluta

ggplot(data_plot, aes(x = `Producing Formation`, y = Fi, fill = `Producing Formation`)) +
  geom_bar(stat = "identity", show.legend = FALSE) +
  geom_text(aes(label = comma(Fi)), vjust = -0.5, family = "Lora", size = 4) + # Fuente Lora aquí
  scale_fill_manual(values = paleta_azul) +
  theme_minimal() +
  labs(title = "Gráfica N°1: Frecuencia Absoluta", x = "Formación", y = "Número de Pozos (Fi)") +
  theme(
    text = element_text(family = "Lora"), # Fuente Lora global en el tema
    plot.title = element_text(face = "bold", hjust = 0.5, size = 18),
    axis.text.x = element_text(angle = 45, hjust = 1)
  )

5.2 Gráfica N°2: Distribución Porcentual

ggplot(data_plot, aes(x = `Producing Formation`, y = Pi, fill = `Producing Formation`)) +
  geom_bar(stat = "identity", show.legend = FALSE) +
  geom_text(aes(label = paste0(round(Pi, 1), "%")), vjust = -0.5, family = "Lora", size = 4) + # Fuente Lora aquí
  scale_fill_manual(values = paleta_azul) +
  theme_minimal() +
  labs(title = "Gráfica N°2: Distribución Porcentual", x = "Formación", y = "Porcentaje (%)") +
  theme(
    text = element_text(family = "Lora"), # Fuente Lora global en el tema
    plot.title = element_text(face = "bold", hjust = 0.5, size = 18),
    axis.text.x = element_text(angle = 45, hjust = 1)
  )

5.3 Gráfica N°3: Diagrama Circular

# Gráfico circular limpio, sin etiquetas externas amontonadas
ggplot(tabla_final, aes(x = "", y = Pi, fill = reorder(`Producing Formation`, -Pi))) +
  geom_bar(stat = "identity", width = 1, color = "white") +
  coord_polar("y", start = 0) +
  # Solo etiquetas internas para los valores grandes, con fuente Lora
  geom_text(aes(label = ifelse(Pi > 5, paste0(round(Pi, 1), "%"), "")),
            position = position_stack(vjust = 0.5), 
            color = "white", fontface = "bold", size = 5, family = "Lora") + # Fuente Lora aquí
  scale_fill_manual(values = paleta_azul) +
  theme_void() +
  labs(title = "Gráfica N°3: Diagrama Circular", fill = "Formación") +
  theme(
    text = element_text(family = "Lora"), # Fuente Lora global en el tema
    plot.title = element_text(face = "bold", hjust = 0.5, size = 18)
  )

6. Tabla de Indicadores

# Calculamos los valores necesarios
indicadores <- data.frame(
  Indicador = c("Total de Pozos", "Moda", "Porcentaje de la Moda"),
  Valor = c(comma(sum(tabla_final$Fi, na.rm = TRUE)), 
            as.character(tabla_final[["Producing Formation"]][1]), 
            paste0(round(tabla_final$Pi[1], 2), "%"))
)

# Generamos la tabla con estilo profesional
indicadores %>%
  kbl(caption = "<center><b>TABLA 2. Indicadores Estadísticos</b></center>", 
      align = "lc", escape = FALSE) %>%
  kable_styling(bootstrap_options = c("hover", "striped"), full_width = TRUE, html_font = "Lora") %>%
  row_spec(0, background = "#1D4E73", color = "white", bold = TRUE) %>%
  footnote(general = "Autor: Jennifer Cordones", general_title = "")
TABLA 2. Indicadores Estadísticos
Indicador Valor
Total de Pozos 32,946
Moda Richburg
Porcentaje de la Moda 26.88%
Autor: Jennifer Cordones

7. Conclusión

El análisis realizado sobre la variable PRODUCING FORMATION destaca que la formación Richburg es la predominante, representando el 26.9% del total de pozos.