knitr::opts_chunk$set(echo = TRUE)
setwd("C:/Users/LEO/Documents/ESTA")
Datos <- read.csv("tabela_de_pocos_janeiro_2018.csv", header = TRUE, sep = ";" , dec = ".", fileEncoding = "Latin1")
str(Datos)
## 'data.frame': 29575 obs. of 1 variable:
## $ ï..POCO.CADASTRO.OPERADOR.POCO_OPERADOR.ESTADO.BACIA.BLOCO.SIG_CAMPO.CAMPO.TERRA_MAR.POCO_POS_ANP.TIPO.CATEGORIA.RECLASSIFICACAO.SITUACAO.INICIO.TERMINO.CONCLUSAO.TITULARIDADE.LATITUDE_BASE_4C.LONGITUDE_BASE_4C.LATITUDE_BASE_DD.LONGITUDE_BASE_DD.DATUM_HORIZONTAL.TIPO_DE_COORDENADA_DE_BASE.DIRECAO.PROFUNDIDADE_VERTICAL_M.PROFUNDIDADE_SONDADOR_M.PROFUNDIDADE_MEDIDA_M.REFERENCIA_DE_PROFUNDIDADE.MESA_ROTATIVA.COTA_ALTIMETRICA_M.LAMINA_D_AGUA_M.DATUM_VERTICAL.UNIDADE_ESTRATIGRAFICA.GEOLOGIA_GRUPO_FINAL.GEOLOGIA_FORMACAO_FINAL.GEOLOGIA_MEMBRO_FINAL.CDPE.AGP.PC.PAG.PERFIS_CONVENCIONAIS.DURANTE_PERFURACAO.PERFIS_DIGITAIS.PERFIS_PROCESSADOS.PERFIS_ESPECIAIS.AMOSTRA_LATERAL.SISMICA.TABELA_TEMPO_PROFUNDIDADE.DADOS_DIRECIONAIS.TESTE_A_CABO.TESTE_DE_FORMACAO.CANHONEIO.TESTEMUNHO.GEOQUIMICA.SIG_SONDA.NOM_SONDA.DHA_ATUALIZACAO: chr "7-RO-123HP-RJS,74281026087,Petrobras,7RO123HPRJS,RJ,Campos,,RO ,RONCADOR,M,S,Explotatório,Desenvolvimento,PR"| __truncated__ "1-BP-7-RJS,74281026107,BP Energy,ANU,RJ,Campos,C-M-473,,,M,S,Exploratório,Pioneiro,PORTADOR DE PETRÃ\u0093LEO,"| __truncated__ "7-ARGO-4H-ESS,34281026170,Shell Brasil,7ARGO4HESS,ES,Campos,,ARGO ,ARGONAUTA,M,S,Explotatório,Desenvolvimento,"| __truncated__ "7-ARGO-5H-ESS,34281026180,Shell Brasil,7ARGO5HESS,ES,Campos,,ARGO ,ARGONAUTA,M,S,Explotatório,Desenvolvimento,"| __truncated__ ...
El presente informe estadístico analiza la variable Profundidad Vertical de pozos petroleros de Brasil.
# 1. LIBRERÍAS Y CARGA DE DATOS
library(readxl)
library(dplyr)
##
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(gt)
library(e1071)
# Carga de datos
Datos_Brutos <- read_xlsx("C:/Users/LEO/Documents/ESTA/tabela_de_pocos_janeiro_2018.xlsx", sheet = 1)
colnames(Datos_Brutos) <- trimws(colnames(Datos_Brutos))
Datos <- Datos_Brutos %>%
select(any_of(c("POCO", "PROFUNDIDADE_VERTICAL_M"))) %>%
mutate(Variable_Analisis = as.numeric(gsub(",", ".", as.character(PROFUNDIDADE_VERTICAL_M))))
Variable <- na.omit(Datos$Variable_Analisis)
Variable <- Variable[Variable > 0 & Variable < 15000]
if(length(Variable) == 0) {
stop("ERROR")
}
# 2. CÁLCULOS MATEMÁTICOS PARA LA TABLA
N <- length(Variable)
K <- floor(1 + 3.322 * log10(N))
breaks_table <- seq(min(Variable), max(Variable), length.out = K + 1)
# Cálculo de ni usando cut (reemplaza el bucle for y maneja los límites Li y Ls)
ni <- as.vector(table(cut(Variable, breaks = breaks_table, include.lowest = TRUE, right = FALSE)))
# Cálculo de vectores estadísticos
hi <- (ni / sum(ni)) * 100
Ni_asc <- cumsum(ni)
Ni_desc <- rev(cumsum(rev(ni)))
Hi_asc <- cumsum(hi)
Hi_desc <- rev(cumsum(rev(hi)))
# Creación de la Tabla de Distribución de Frecuencias (TDF)
TDF_Profundidad <- data.frame(
Li = round(breaks_table[1:K], 2),
Ls = round(breaks_table[2:(K+1)], 2),
MC = round((breaks_table[1:K] + breaks_table[2:(K+1)]) / 2, 2),
ni = ni,
hi = round(hi, 2),
Ni_asc = Ni_asc,
Ni_desc = Ni_desc,
Hi_asc = round(Hi_asc, 2),
Hi_desc = round(Hi_desc, 2)
)
A continuación se presenta la tabla de distribución de frecuencias obtenida.
TDF_Profundidad %>%
gt() %>%
tab_header(
title = md("**DISTRIBUCIÓN DE FRECUENCIAS DE POZOS PETROLEROS DE BRASIL**"),
subtitle = md("Variable: **Profundidad Vertical (m)**")
) %>%
tab_source_note(source_note = "Fuente: Datos ANP 2018") %>%
# Totales automáticos sin necesidad de rbind o TDF_Final
grand_summary_rows(
columns = c(ni, hi),
fns = list(TOTAL = ~sum(.)),
formatter = fmt_number, decimals = 0
) %>%
cols_label(
Li = "Lím. Inf", Ls = "Lím. Sup", MC = "Marca Clase (Xi)",
ni = "ni", hi = "hi (%)",
Ni_asc = "Ni (Asc)", Ni_desc = "Ni (Desc)",
Hi_asc = "Hi (Asc)", Hi_desc = "Hi (Desc)"
) %>%
cols_align(align = "center", columns = everything()) %>%
# Estilos unificados
tab_style(
style = list(cell_fill(color = "#2E4053"), cell_text(color = "white", weight = "bold")),
locations = list(cells_title(), cells_column_labels())
) %>%
tab_options(
table.border.top.color = "#2E4053",
table.border.bottom.color = "#2E4053",
column_labels.border.bottom.color = "#2E4053",
data_row.padding = px(6)
)
## Warning: Since gt v0.9.0, the `formatter` argument (and associated `...`) has been
## deprecated.
## • Please use the `fmt` argument to provide formatting directives.
## This warning is displayed once every 8 hours.
| DISTRIBUCIÓN DE FRECUENCIAS DE POZOS PETROLEROS DE BRASIL | |||||||||
| Variable: Profundidad Vertical (m) | |||||||||
| Lím. Inf | Lím. Sup | Marca Clase (Xi) | ni | hi (%) | Ni (Asc) | Ni (Desc) | Hi (Asc) | Hi (Desc) | |
|---|---|---|---|---|---|---|---|---|---|
| 4.00 | 636.42 | 320.21 | 526 | 21.35 | 526 | 2464 | 21.35 | 100.00 | |
| 636.42 | 1268.83 | 952.62 | 691 | 28.04 | 1217 | 1938 | 49.39 | 78.65 | |
| 1268.83 | 1901.25 | 1585.04 | 277 | 11.24 | 1494 | 1247 | 60.63 | 50.61 | |
| 1901.25 | 2533.67 | 2217.46 | 280 | 11.36 | 1774 | 970 | 72.00 | 39.37 | |
| 2533.67 | 3166.08 | 2849.88 | 343 | 13.92 | 2117 | 690 | 85.92 | 28.00 | |
| 3166.08 | 3798.50 | 3482.29 | 129 | 5.24 | 2246 | 347 | 91.15 | 14.08 | |
| 3798.50 | 4430.92 | 4114.71 | 56 | 2.27 | 2302 | 218 | 93.43 | 8.85 | |
| 4430.92 | 5063.33 | 4747.12 | 70 | 2.84 | 2372 | 162 | 96.27 | 6.57 | |
| 5063.33 | 5695.75 | 5379.54 | 54 | 2.19 | 2426 | 92 | 98.46 | 3.73 | |
| 5695.75 | 6328.17 | 6011.96 | 23 | 0.93 | 2449 | 38 | 99.39 | 1.54 | |
| 6328.17 | 6960.58 | 6644.38 | 12 | 0.49 | 2461 | 15 | 99.88 | 0.61 | |
| 6960.58 | 7593.00 | 7276.79 | 3 | 0.12 | 2464 | 3 | 100.00 | 0.12 | |
| TOTAL | — | — | — | 2,464 | 100 | — | — | — | — |
| Fuente: Datos ANP 2018 | |||||||||
Esta sección presenta la visualización de la distribución de los datos.
col_gris_azulado <- "#5D6D7E"
col_ejes <- "#2E4053"
h_base <- hist(Variable, breaks = "Sturges", plot = FALSE)
# GRÁFICO 1: Histograma Absoluto (Local)
par(mar = c(8, 5, 4, 2))
plot(h_base,
main = "Gráfica No.1: Distribución de Profundidad Vertical de Pozos Petroleros de Brasil",
xlab = "Profundidad Vertical (m)",
ylab = "Frecuencia Absoluta",
col = col_gris_azulado, border = "white", axes = FALSE,
ylim = c(0, max(h_base$counts) * 1.1))
axis(1, at = round(h_base$breaks, 0), labels = format(round(h_base$breaks, 0), scientific = FALSE), las = 2, cex.axis = 0.7)
axis(2)
grid(nx=NA, ny=NULL, col="#D7DBDD", lty="dotted")
# GRÁFICO 2: Histograma Global
par(mar = c(8, 5, 4, 2))
plot(h_base,
main = "Gráfica N°2: Distribución de Profundidad Vertical de Pozos Petroleros de Brasil",
xlab = "Profundidad Vertical (m)",
ylab = "Total Pozos",
col = col_gris_azulado, border = "white", axes = FALSE,
ylim = c(0, sum(h_base$counts)))
axis(1, at = round(h_base$breaks, 0), labels = format(round(h_base$breaks, 0), scientific = FALSE), las = 2, cex.axis = 0.7)
axis(2)
grid(nx=NA, ny=NULL, col="#D7DBDD", lty="dotted")
h_porc <- h_base
h_porc$counts <- (h_porc$counts / sum(h_porc$counts)) * 100
h_porc$density <- h_porc$counts
# GRÁFICO 3: Porcentajes (Local)
par(mar = c(8, 5, 4, 2))
plot(h_porc,
main = "Gráfica N°3: Distribución Porcentual de Profundidad Vertical de Pozos Petroleros de Brasil",
xlab = "Profundidad Vertical (m)",
ylab = "Porcentaje (%)",
col = col_gris_azulado, border = "white", axes = FALSE, freq = TRUE,
ylim = c(0, max(h_porc$counts)*1.2))
axis(1, at = round(h_base$breaks, 0), labels = format(round(h_base$breaks, 0), scientific = FALSE), las = 2, cex.axis = 0.7)
axis(2)
text(x = h_base$mids, y = h_porc$counts, label = paste0(round(h_porc$counts, 1), "%"), pos = 3, cex = 0.6, col = col_ejes)
grid(nx=NA, ny=NULL, col="#D7DBDD", lty="dotted")
# GRÁFICO 4: Global Porcentual
par(mar = c(8, 5, 4, 2))
plot(h_porc,
main = "Gráfica No.4: Distribución Porcentual de Profundidad Vertical de Pozos Petroleros de Brasil",
xlab = "Profundidad Vertical (m)",
ylab = "% del Total",
col = col_gris_azulado, border = "white", axes = FALSE, freq = TRUE,
ylim = c(0, 100))
axis(1, at = round(h_base$breaks, 0), labels = format(round(h_base$breaks, 0), scientific = FALSE), las = 2, cex.axis = 0.7)
text(x = h_base$mids, y = h_porc$counts, label = paste0(round(h_porc$counts, 1), "%"), pos = 3, cex = 0.6, col = col_ejes)
axis(2)
abline(h=seq(0,100,20), col="#D7DBDD", lty="dotted")
# GRÁFICO 5: Boxplot
par(mar = c(5, 5, 4, 2))
boxplot(Variable, horizontal = TRUE, col = col_gris_azulado,
main = "Gráfica No.5: Diagrama de Caja de Profundidad Vertical de Pozos Petroleros de Brasil (Boxplot)",
xlab = "Profundidad Vertical (m)", outline = TRUE, outpch = 19, outcol = "#C0392B",
boxwex = 0.5, frame.plot = FALSE, xaxt = "n")
eje_x_detallado <- pretty(Variable, n = 20)
axis(1, at = eje_x_detallado, labels = format(eje_x_detallado, scientific = FALSE), cex.axis=0.7, las=2)
grid(nx=NULL, ny=NA, col="lightgray", lty="dotted")
# GRÁFICO 6: Ojivas
par(mar = c(5, 5, 4, 8), xpd = TRUE)
x_asc <- c(min(breaks_table), breaks_table[2:length(breaks_table)])
y_asc <- c(0, Ni_asc)
x_desc <- c(min(breaks_table), breaks_table[2:length(breaks_table)])
y_desc <- c(Ni_desc, 0)
x_range <- range(c(x_asc, x_desc))
y_range <- c(0, max(c(y_asc, y_desc)))
col_azul <- "#2E4053"
col_rojo <- "#C0392B"
plot(x_asc, y_asc, type = "o", col = col_azul, lwd=2, pch=19,
main = "Gráfica No.6: Ojivas Ascendente y Descendente de Profundidad Vertical de Pozos Petroleros de Brasil",
xlab = "Profundidad Vertical (m)", ylab = "Frecuencia acumulada",
xlim = x_range, ylim = y_range, axes = FALSE, frame.plot = FALSE, cex.main=0.95)
axis(1, at = round(breaks_table,0), labels = format(round(breaks_table,0), scientific = FALSE), las=2, cex.axis=0.6)
axis(2, at = pretty(y_asc), labels = format(pretty(y_asc), scientific = FALSE))
lines(x_asc, y_desc, type = "o", col = col_rojo, lwd=2, pch=19)
legend("right", legend = c("Ascendente", "Descendente"),
col = c(col_azul, col_rojo), lty = 1, pch = 19, cex = 0.7, lwd=2,
inset = c(-0.15, 0), bty="n")
grid()
# CÁLCULO DE INDICADORES
media_val <- mean(Variable)
mediana_val <- median(Variable)
sd_val <- sd(Variable)
# Moda y Rango
moda_txt <- paste(round(TDF_Profundidad$MC[TDF_Profundidad$ni == max(TDF_Profundidad$ni)], 2), collapse = ", ")
rango_txt <- paste0("[", round(min(Variable), 2), "; ", round(max(Variable), 2), "]")
# Atípicos (Outliers)
vals_atipicos <- boxplot.stats(Variable)$out
status_atipicos <- if(length(vals_atipicos) > 0) {
paste0(length(vals_atipicos), " [", round(min(vals_atipicos), 2), "; ", round(max(vals_atipicos), 2), "]")
} else { "0 (Sin atípicos)" }
# Creación del DataFrame de Resumen
df_resumen <- data.frame(
Variable = "Profundidad Vertical (m)",
Rango = rango_txt,
Media = media_val,
Mediana = mediana_val,
Moda = moda_txt,
Varianza = var(Variable),
Desv_Std = sd_val,
CV_Porc = (sd_val / abs(media_val)) * 100,
Asimetria = skewness(Variable, type = 2),
Curtosis = kurtosis(Variable, type = 2), # Corregido: 'kurtosis' con k
Atipicos = status_atipicos
)
# 2. TABLA GT PROFESIONAL
df_resumen %>%
gt() %>%
tab_header(
title = md("**CONCLUSIONES Y ESTADÍSTICOS**"),
subtitle = "Resumen de Indicadores de Profundidad Vertical de Pozos Petroleros de Brasil"
) %>%
tab_source_note(source_note = "Autor: Grupo 3") %>%
fmt_number(columns = c(Media, Mediana, Varianza, Desv_Std, CV_Porc, Curtosis), decimals = 2) %>%
fmt_number(columns = Asimetria, decimals = 4) %>%
cols_label(
Rango = "Rango Total", Media = "Media (X̄)", Mediana = "Mediana (Me)",
Moda = "Moda (Mo)", Varianza = "Varianza (S²)", Desv_Std = "Desv. Est. (S)",
CV_Porc = "C.V. (%)", Asimetria = "Asimetría (As)", Curtosis = "Curtosis (K)",
Atipicos = "Outliers [Intervalo]"
) %>%
tab_options(
column_labels.background.color = "#2E4053",
table.border.bottom.color = "#2E4053",
data_row.padding = px(8)
) %>%
tab_style(
style = list(cell_text(weight = "bold", color = "white")),
locations = cells_column_labels()
)
| CONCLUSIONES Y ESTADÍSTICOS | ||||||||||
| Resumen de Indicadores de Profundidad Vertical de Pozos Petroleros de Brasil | ||||||||||
| Variable | Rango Total | Media (X̄) | Mediana (Me) | Moda (Mo) | Varianza (S²) | Desv. Est. (S) | C.V. (%) | Asimetría (As) | Curtosis (K) | Outliers [Intervalo] |
|---|---|---|---|---|---|---|---|---|---|---|
| Profundidad Vertical (m) | [4; 7593] | 1,776.12 | 1,302.90 | 952.62 | 1,973,998.51 | 1,404.99 | 79.10 | 1.1579 | 0.92 | 41 [5653.8; 7593] |
| Autor: Grupo 3 | ||||||||||
min_txt <- format(min(Variable), scientific = FALSE)
max_txt <- format(max(Variable), scientific = FALSE)
asimetria_val <- skewness(Variable, type = 2)
if (abs(asimetria_val) > 0.5) {
centro_valor <- format(round(median(Variable), 2), scientific = FALSE)
} else {
centro_valor <- format(round(mean(Variable), 2), scientific = FALSE)
}
sd_txt <- format(round(sd(Variable), 4), scientific = FALSE)
cv_calc <- (sd(Variable) / abs(mean(Variable))) * 100
tipo_homogeneidad <- if(cv_calc > 30) "heterogénea" else "homogénea"
donde_se_concentra <- if(asimetria_val > 0) "parte media baja" else "parte media alta"
outliers_lista <- boxplot.stats(Variable)$out
num_outliers <- length(outliers_lista)
texto_outliers <- if(num_outliers > 0) {
paste0("con la presencia de **", num_outliers, " valores atípicos**")
} else {
"sin valores atípicos significativos"
}
umbral_profundidad_economica <- 3000
juicio_economico <- if(median(Variable) < umbral_profundidad_economica) {
"favorable en términos de rentabilidad, dado que una menor profundidad vertical implica una reducción significativa en la inversión económica (CAPEX/días de taladro) e indica la presencia de zonas de exploración prospectivas que no requieren alcanzar grandes profundidades para el hallazgo de hidrocarburos"
} else {
"exigente en términos de inversión, ya que las profundidades registradas demandan mayores recursos técnicos y financieros (alto CAPEX), característicos de yacimientos profundos o escenarios de alta complejidad geológica"
}
cat(paste0(
"## Análisis Descriptivo y Económico\n\n",
"La variable **Profundidad Vertical** fluctúa entre **", min_txt, "** y **", max_txt, "** metros, ",
"y sus valores se encuentran alrededor de **", centro_valor, "** metros. ",
"Presenta una desviación estándar de **", sd_txt, "**, siendo una variable **", tipo_homogeneidad, "** ",
"(CV: ", round(cv_calc, 2), "%), ",
"cuyos valores se concentran en la **", donde_se_concentra, "** de la distribución ",
texto_outliers, "; ",
"**por todo lo anterior, el comportamiento de la variable se considera ", juicio_economico, ".**"
))
## ## Análisis Descriptivo y Económico
##
## La variable **Profundidad Vertical** fluctúa entre **4** y **7593** metros, y sus valores se encuentran alrededor de **1302.9** metros. Presenta una desviación estándar de **1404.991**, siendo una variable **heterogénea** (CV: 79.1%), cuyos valores se concentran en la **parte media baja** de la distribución con la presencia de **41 valores atípicos**; **por todo lo anterior, el comportamiento de la variable se considera favorable en términos de rentabilidad, dado que una menor profundidad vertical implica una reducción significativa en la inversión económica (CAPEX/días de taladro) e indica la presencia de zonas de exploración prospectivas que no requieren alcanzar grandes profundidades para el hallazgo de hidrocarburos.**