library(readxl)
Produccio_n_Campo_Sacha_csv <- read_excel("Producción Campo Sacha.csv.xlsx")
View(Produccio_n_Campo_Sacha_csv)
str(Produccio_n_Campo_Sacha_csv)
## tibble [8,344 × 31] (S3: tbl_df/tbl/data.frame)
## $ mes : chr [1:8344] "Ene" "Ene" "Ene" "Ene" ...
## $ día : num [1:8344] 1 1 1 1 1 1 1 1 1 1 ...
## $ Pozo : chr [1:8344] "SACHA-001A" "SACHA-019A" "SACHA-052B" "SACHA-083A" ...
## $ Campo : chr [1:8344] "SACHA" "SACHA" "SACHA" "SACHA" ...
## $ Reservorio : chr [1:8344] "U" "U" "U INFERIOR" "HOLLIN INFERIOR" ...
## $ Bpd : num [1:8344] NA 53 249 139 186 136 NA 456 161 164 ...
## $ Bppd_BH : num [1:8344] 159 NA NA NA NA NA 155 NA NA NA ...
## $ Bfpd_BE : num [1:8344] NA 534 346 1158 1163 ...
## $ Bfpd_BH : num [1:8344] 695 NA NA NA NA NA 441 NA NA NA ...
## $ Bapd_BE : num [1:8344] NA 481 97 1019 977 ...
## $ Bapd_BH : num [1:8344] 536 NA NA NA NA NA 286 NA NA NA ...
## $ Bsw_BE : num [1:8344] NA 90.1 28 88 84 ...
## $ Bsw_BH : num [1:8344] 77.1 NA NA NA NA ...
## $ Api_BE : num [1:8344] NA 26.7 27.8 27.7 24 20.5 NA 28.5 29.9 26.3 ...
## $ Api_BH : num [1:8344] 27.8 NA NA NA NA NA 23.2 NA NA NA ...
## $ Gas_BE : num [1:8344] NA 10.76 50.55 1.11 27.9 ...
## $ Gas_BH : num [1:8344] 32.3 NA NA NA NA ...
## $ Salinidad_BE : num [1:8344] NA 15920 30227 1600 13000 ...
## $ Salinidad_BH : num [1:8344] 10800 NA NA NA NA NA 3800 NA NA NA ...
## $ Rgl_BE : num [1:8344] NA 20.15 146.1 0.96 23.99 ...
## $ Rgl_BH : num [1:8344] 46.5 NA NA NA NA ...
## $ Gor_BE : num [1:8344] NA 203.02 203.01 7.99 150 ...
## $ Gor_BH : num [1:8344] 203 NA NA NA NA ...
## $ Horas_BE : num [1:8344] NA 4 5 4 4 10 NA 4 10 10 ...
## $ Horas_BH : num [1:8344] 4 NA NA NA NA NA 4 NA NA NA ...
## $ Bomba_BE : chr [1:8344] NA "SF-320|SF-320|SF-900|SFGH2500/520/180/9259" "RC 1000|RC 1000|RC 1000/300/120/9250" "P23/68/30/7000" ...
## $ Bomba_BH : chr [1:8344] "JET 12K/0//0" NA NA NA ...
## $ Frecuencia Operaciones: num [1:8344] NA 65 62 46 59 52 NA 58.5 57 54 ...
## $ Voltaje : num [1:8344] NA 479 457 364 440 452 NA 475 455 439 ...
## $ Amperaje : num [1:8344] NA 29 35 14 59 30 NA 23 35 34 ...
## $ Presión Intake : num [1:8344] NA 484 406 0 345 162 NA 546 338 0 ...
# 1 Extraer la variable continua
api_be <- Produccio_n_Campo_Sacha_csv$Api_BE
api_be <- as.numeric(api_be)
api_be <- na.omit(api_be)
k <- 1 + (3.3 * log10(length(api_be)))
k <- floor(k)
min <- min(api_be)
max <- max(api_be)
R <- max - min
A <- R / k
# Líneas EXACTAS del ejemplo del enlace:
Li <- round(seq(from = min, to = max - A, by = A), 4)
Ls <- round(seq(from = min + A, to = max, by = A), 4)
MC <- round((Li + Ls) / 2, 2)
ni <- numeric(length(Li))
for (i in 1:length(Li)) {
ni[i] <- sum(api_be >= Li[i] & api_be < Ls[i])
}
ni[length(Li)] <- sum(api_be >= Li[length(Li)] & api_be <= max)
cat("Suma de ni =", sum(ni), "\n")
## Suma de ni = 7705
hi <- ni / sum(ni) * 100
cat("Suma de hi =", sum(hi), "\n")
## Suma de hi = 100
Niasc <- cumsum(ni)
Nidsc <- rev(cumsum(rev(ni)))
Hiasc <- round(cumsum(hi))
Hidsc <- round(rev(cumsum(rev(hi))))
TDFApiBE <- data.frame(Li, Ls, MC, ni, hi, Niasc, Nidsc, Hiasc, Hidsc)
library(gt)
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
tabla1_sturges <- TDFApiBE %>%
gt() %>%
tab_header(
title = md("*Tabla 1: Distribución de Frecuencias*"),
subtitle = md("**Método Sturges - Variable: Api_BE**")
) %>%
tab_source_note(
source_note = md("Campo Sacha")
) %>%
cols_label(
Li = "L. Inferior",
Ls = "L. Superior",
MC = "Marca Clase",
ni = "Frec. Abs.",
hi = "Frec. Rel. %",
Niasc = "Ni Asc.",
Nidsc = "Ni Desc.",
Hiasc = "Hi Asc. %",
Hidsc = "Hi Desc. %"
) %>%
fmt_number(
columns = c(Li, Ls, MC),
decimals = 2
) %>%
fmt_number(
columns = c(hi),
decimals = 2,
pattern = "{x}%"
)
cat("\n=== TABLA 1: MÉTODO STURGES ===\n")
##
## === TABLA 1: MÉTODO STURGES ===
tabla1_sturges
| Tabla 1: Distribución de Frecuencias | ||||||||
| Método Sturges - Variable: Api_BE | ||||||||
| L. Inferior | L. Superior | Marca Clase | Frec. Abs. | Frec. Rel. % | Ni Asc. | Ni Desc. | Hi Asc. % | Hi Desc. % |
|---|---|---|---|---|---|---|---|---|
| 0.00 | 2.89 | 1.45 | 5 | 0.06% | 5 | 7705 | 0 | 100 |
| 2.89 | 5.78 | 4.34 | 1 | 0.01% | 6 | 7700 | 0 | 100 |
| 5.78 | 8.68 | 7.23 | 0 | 0.00% | 6 | 7699 | 0 | 100 |
| 8.68 | 11.57 | 10.12 | 0 | 0.00% | 6 | 7699 | 0 | 100 |
| 11.57 | 14.46 | 13.02 | 11 | 0.14% | 17 | 7699 | 0 | 100 |
| 14.46 | 17.35 | 15.91 | 104 | 1.35% | 121 | 7688 | 2 | 100 |
| 17.35 | 20.25 | 18.80 | 1564 | 20.30% | 1685 | 7584 | 22 | 98 |
| 20.25 | 23.14 | 21.69 | 788 | 10.23% | 2473 | 6020 | 32 | 78 |
| 23.14 | 26.03 | 24.58 | 2176 | 28.24% | 4649 | 5232 | 60 | 68 |
| 26.03 | 28.92 | 27.48 | 1809 | 23.48% | 6458 | 3056 | 84 | 40 |
| 28.92 | 31.82 | 30.37 | 1012 | 13.13% | 7470 | 1247 | 97 | 16 |
| 31.82 | 34.71 | 33.26 | 205 | 2.66% | 7675 | 235 | 100 | 3 |
| 34.71 | 37.60 | 36.15 | 30 | 0.39% | 7705 | 30 | 100 | 0 |
| Campo Sacha | ||||||||
total_ni <- sum(TDFApiBE$ni)
total_hi <- 100
TDFApiBECompleto <- rbind(
TDFApiBE,
data.frame(
Li = " Total",
Ls = " ",
MC = " ",
ni = total_ni,
hi = total_hi,
Niasc = " ",
Nidsc = " ",
Hiasc = " ",
Hidsc = " "
)
)
#### TABLA 2 FORMATEADA: Con Total (TDFApi_BECompleto)
tabla2_con_total <- TDFApiBECompleto %>%
gt() %>%
tab_header(
title = md("*Tabla 2: Distribución Completa*"),
subtitle = md("**Variable: Api_BE - Con Total**")
) %>%
tab_source_note(
source_note = md("Fuente: Producción Campo Sacha")
) %>%
tab_style(
style = cell_text(weight = "bold"),
locations = cells_body(rows = Li == " Total")
) %>%
cols_label(
Li = "L. Inferior",
Ls = "L. Superior",
MC = "Marca Clase",
ni = "Frec. Abs.",
hi = "Frec. Rel. %",
Niasc = "Ni Asc.",
Nidsc = "Ni Desc.",
Hiasc = "Hi Asc. %",
Hidsc = "Hi Desc. %"
)
cat("\n=== TABLA 2: CON FILA DE TOTAL ===\n")
##
## === TABLA 2: CON FILA DE TOTAL ===
tabla2_con_total
| Tabla 2: Distribución Completa | ||||||||
| Variable: Api_BE - Con Total | ||||||||
| L. Inferior | L. Superior | Marca Clase | Frec. Abs. | Frec. Rel. % | Ni Asc. | Ni Desc. | Hi Asc. % | Hi Desc. % |
|---|---|---|---|---|---|---|---|---|
| 0 | 2.8923 | 1.45 | 5 | 0.06489293 | 5 | 7705 | 0 | 100 |
| 2.8923 | 5.7846 | 4.34 | 1 | 0.01297859 | 6 | 7700 | 0 | 100 |
| 5.7846 | 8.6769 | 7.23 | 0 | 0.00000000 | 6 | 7699 | 0 | 100 |
| 8.6769 | 11.5692 | 10.12 | 0 | 0.00000000 | 6 | 7699 | 0 | 100 |
| 11.5692 | 14.4615 | 13.02 | 11 | 0.14276444 | 17 | 7699 | 0 | 100 |
| 14.4615 | 17.3538 | 15.91 | 104 | 1.34977287 | 121 | 7688 | 2 | 100 |
| 17.3538 | 20.2462 | 18.8 | 1564 | 20.29850746 | 1685 | 7584 | 22 | 98 |
| 20.2462 | 23.1385 | 21.69 | 788 | 10.22712524 | 2473 | 6020 | 32 | 78 |
| 23.1385 | 26.0308 | 24.58 | 2176 | 28.24140169 | 4649 | 5232 | 60 | 68 |
| 26.0308 | 28.9231 | 27.48 | 1809 | 23.47826087 | 6458 | 3056 | 84 | 40 |
| 28.9231 | 31.8154 | 30.37 | 1012 | 13.13432836 | 7470 | 1247 | 97 | 16 |
| 31.8154 | 34.7077 | 33.26 | 205 | 2.66060999 | 7675 | 235 | 100 | 3 |
| 34.7077 | 37.6 | 36.15 | 30 | 0.38935756 | 7705 | 30 | 100 | 0 |
| Total | 7705 | 100.00000000 | ||||||
| Fuente: Producción Campo Sacha | ||||||||
histo_ApiBE <- hist(api_be,
main = "Gráfica: Distribución de Api_BE\nCampo Sacha",
xlab = "Api_BE",
ylab = "Cantidad",
col = "lightblue",
border = "darkblue",
las = 1)
#### Creación de la tabla de distribución de frecuencia
Limites <- histo_ApiBE$breaks
LimInf <- Limites[1:(length(Limites)-1)]
LimSup <- Limites[2:length(Limites)]
Mc <- histo_ApiBE$mids
ni_R <- histo_ApiBE$counts
cat("\nSuma de ni (R automático) =", sum(ni_R), "\n")
##
## Suma de ni (R automático) = 7705
hi_R <- ni_R / sum(ni_R) * 100
cat("Suma de hi (R automático) =", sum(hi_R), "\n")
## Suma de hi (R automático) = 100
Ni_asc <- cumsum(ni_R)
Ni_dsc <- rev(cumsum(rev(ni_R)))
Hi_asc <- round(cumsum(hi_R), 2)
Hi_dsc <- round(rev(cumsum(rev(hi_R))), 2)
TDF_ApiBE_R <- data.frame(LimInf, LimSup, Mc, ni_R, hi_R,
Ni_asc, Ni_dsc, Hi_asc, Hi_dsc)
tabla3_R_auto <- TDF_ApiBE_R %>%
gt() %>%
tab_header(
title = md("*Tabla 3: Distribución - Intervalos R*"),
subtitle = md("**Método Automático de R - Variable: Api_BE**")
) %>%
tab_source_note(
source_note = md("Intervalos generados automáticamente por hist()")
) %>%
cols_label(
LimInf = "L. Inferior",
LimSup = "L. Superior",
Mc = "Marca Clase",
ni_R = "Frec. Abs.",
hi_R = "Frec. Rel. %",
Ni_asc = "Ni Asc.",
Ni_dsc = "Ni Desc.",
Hi_asc = "Hi Asc. %",
Hi_dsc = "Hi Desc. %"
) %>%
fmt_number(
columns = c(hi_R, Hi_asc, Hi_dsc),
decimals = 2,
pattern = "{x}%"
)
cat("\n=== TABLA 3: INTERVALOS AUTOMÁTICOS DE R ===\n")
##
## === TABLA 3: INTERVALOS AUTOMÁTICOS DE R ===
tabla3_R_auto
| Tabla 3: Distribución - Intervalos R | ||||||||
| Método Automático de R - Variable: Api_BE | ||||||||
| L. Inferior | L. Superior | Marca Clase | Frec. Abs. | Frec. Rel. % | Ni Asc. | Ni Desc. | Hi Asc. % | Hi Desc. % |
|---|---|---|---|---|---|---|---|---|
| 0 | 2 | 1 | 5 | 0.06% | 5 | 7705 | 0.06% | 100.00% |
| 2 | 4 | 3 | 0 | 0.00% | 5 | 7700 | 0.06% | 99.94% |
| 4 | 6 | 5 | 1 | 0.01% | 6 | 7700 | 0.08% | 99.94% |
| 6 | 8 | 7 | 0 | 0.00% | 6 | 7699 | 0.08% | 99.92% |
| 8 | 10 | 9 | 0 | 0.00% | 6 | 7699 | 0.08% | 99.92% |
| 10 | 12 | 11 | 0 | 0.00% | 6 | 7699 | 0.08% | 99.92% |
| 12 | 14 | 13 | 11 | 0.14% | 17 | 7699 | 0.22% | 99.92% |
| 14 | 16 | 15 | 0 | 0.00% | 17 | 7688 | 0.22% | 99.78% |
| 16 | 18 | 17 | 313 | 4.06% | 330 | 7688 | 4.28% | 99.78% |
| 18 | 20 | 19 | 1203 | 15.61% | 1533 | 7375 | 19.90% | 95.72% |
| 20 | 22 | 21 | 658 | 8.54% | 2191 | 6172 | 28.44% | 80.10% |
| 22 | 24 | 23 | 934 | 12.12% | 3125 | 5514 | 40.56% | 71.56% |
| 24 | 26 | 25 | 1524 | 19.78% | 4649 | 4580 | 60.34% | 59.44% |
| 26 | 28 | 27 | 1183 | 15.35% | 5832 | 3056 | 75.69% | 39.66% |
| 28 | 30 | 29 | 1167 | 15.15% | 6999 | 1873 | 90.84% | 24.31% |
| 30 | 32 | 31 | 487 | 6.32% | 7486 | 706 | 97.16% | 9.16% |
| 32 | 34 | 33 | 147 | 1.91% | 7633 | 219 | 99.07% | 2.84% |
| 34 | 36 | 35 | 68 | 0.88% | 7701 | 72 | 99.95% | 0.93% |
| 36 | 38 | 37 | 4 | 0.05% | 7705 | 4 | 100.00% | 0.05% |
| Intervalos generados automáticamente por hist() | ||||||||
total_ni_R <- sum(TDF_ApiBE_R$ni_R)
total_hi_R <- 100
# Crear tabla con Total
TDF_ApiBE_R_Completo <- rbind(
TDF_ApiBE_R,
data.frame(
LimInf = "Total",
LimSup = " ",
Mc = " ",
ni_R = total_ni_R,
hi_R = total_hi_R,
Ni_asc = " ",
Ni_dsc = " ",
Hi_asc = " ",
Hi_dsc = " "
)
)
# Usar gt (IGUAL que el ejemplo)
library(gt)
library(dplyr)
tabla_ApiBE_Final <- TDF_ApiBE_R_Completo %>%
gt() %>%
tab_header(
title = md("*Tabla de Distribución de Frecuencias*"),
subtitle = md("**Variable: Api_BE - Campo Sacha**")
)
# Mostrar
tabla_ApiBE_Final
| Tabla de Distribución de Frecuencias | ||||||||
| Variable: Api_BE - Campo Sacha | ||||||||
| LimInf | LimSup | Mc | ni_R | hi_R | Ni_asc | Ni_dsc | Hi_asc | Hi_dsc |
|---|---|---|---|---|---|---|---|---|
| 0 | 2 | 1 | 5 | 0.06489293 | 5 | 7705 | 0.06 | 100 |
| 2 | 4 | 3 | 0 | 0.00000000 | 5 | 7700 | 0.06 | 99.94 |
| 4 | 6 | 5 | 1 | 0.01297859 | 6 | 7700 | 0.08 | 99.94 |
| 6 | 8 | 7 | 0 | 0.00000000 | 6 | 7699 | 0.08 | 99.92 |
| 8 | 10 | 9 | 0 | 0.00000000 | 6 | 7699 | 0.08 | 99.92 |
| 10 | 12 | 11 | 0 | 0.00000000 | 6 | 7699 | 0.08 | 99.92 |
| 12 | 14 | 13 | 11 | 0.14276444 | 17 | 7699 | 0.22 | 99.92 |
| 14 | 16 | 15 | 0 | 0.00000000 | 17 | 7688 | 0.22 | 99.78 |
| 16 | 18 | 17 | 313 | 4.06229721 | 330 | 7688 | 4.28 | 99.78 |
| 18 | 20 | 19 | 1203 | 15.61323816 | 1533 | 7375 | 19.9 | 95.72 |
| 20 | 22 | 21 | 658 | 8.53990915 | 2191 | 6172 | 28.44 | 80.1 |
| 22 | 24 | 23 | 934 | 12.12199870 | 3125 | 5514 | 40.56 | 71.56 |
| 24 | 26 | 25 | 1524 | 19.77936405 | 4649 | 4580 | 60.34 | 59.44 |
| 26 | 28 | 27 | 1183 | 15.35366645 | 5832 | 3056 | 75.69 | 39.66 |
| 28 | 30 | 29 | 1167 | 15.14600909 | 6999 | 1873 | 90.84 | 24.31 |
| 30 | 32 | 31 | 487 | 6.32057106 | 7486 | 706 | 97.16 | 9.16 |
| 32 | 34 | 33 | 147 | 1.90785204 | 7633 | 219 | 99.07 | 2.84 |
| 34 | 36 | 35 | 68 | 0.88254380 | 7701 | 72 | 99.95 | 0.93 |
| 36 | 38 | 37 | 4 | 0.05191434 | 7705 | 4 | 100 | 0.05 |
| Total | 7705 | 100.00000000 | ||||||
hist(api_be,
breaks = seq(min, max, A), # Usar TUS intervalos calculados
main = "Gráfica: Frecuencia de Api_BE\n(Campo Sacha - Intervalos propios)",
col = "blue",
xlab = "Api_BE",
ylab = "Cantidad (ni)",
right = FALSE) # Para que sea [Li, Ls)
hist(api_be,
breaks = seq(min, max, A),
main = "Gráfica: Frecuencia de Api_BE\n(Campo Sacha - Global)",
col = "blue",
xlab = "Api_BE",
ylab = "Cantidad",
ylim = c(0, length(api_be))) # length(api_be) = tu n total
barplot(TDFApiBE$hi, # Tus frecuencias relativas (%)
space = 0, # Sin espacio entre barras
col = "blue",
xlab = "Marca de Clase (MC)",
ylab = "Porcentaje (%)",
names.arg = TDFApiBE$MC) # Nombres = Marcas de clase
barplot(TDFApiBE$hi,
space = 0,
main = "Gráfica: Porcentaje de Api_BE\n(Campo Sacha - Global)",
col = "blue",
xlab = "Marca de Clase (MC)",
ylab = "Porcentaje (%)",
names.arg = TDFApiBE$MC,
ylim = c(0, 100)) # Fijar eje Y de 0 a 100%
plot(TDFApiBE$Ls, TDFApiBE$Nidsc,
type = "o", # "o" = puntos con líneas
xlim = c(0, max), # Eje X desde 0 hasta máximo
main = "Gráfica: Ojivas combinadas de Api_BE\n(Campo Sacha)",
ylab = "Frecuencia Acumulada",
col = "blue",
xlab = "Api_BE",
pch = 16)
# Agregar ojiva ascendente
lines(TDFApiBE$Li, TDFApiBE$Niasc,
col = "black",
type = "b", # "b" = puntos con líneas (pero discontinuas)
pch = 16)
# Leyenda
legend("right",
legend = c("Ojiva descendente (Nidsc)", "Ojiva ascendente (Niasc)"),
col = c("blue", "black"),
pch = 16,
lty = 1,
cex = 0.8)
#### 4.1.2 Ojivas combinadas (hi) - Porcentajes
# Gráfico principal (ojiva descendente - porcentajes)
plot(TDFApiBE$Ls, TDFApiBE$Hidsc,
type = "o", # "o" = puntos y líneas
xlim = c(0, max),
main = "Gráfica: Ojivas combinadas de Api_BE\n(Campo Sacha - Porcentajes)",
ylab = "Porcentaje Acumulado (%)",
col = "blue",
xlab = "Api_BE",
ylim = c(0, 100)) # Porcentajes de 0 a 100%
# Agregar ojiva ascendente (porcentajes) - SIN "add=TRUE"
lines(TDFApiBE$Li, TDFApiBE$Hiasc,
col = "black",
type = "b") # "b" = puntos con líneas discontinuas
# Leyenda
legend("right",
legend = c("Ojiva descendente (Hidsc)", "Ojiva ascendente (Hiasc)"),
col = c("blue", "black"),
pch = 1, # Tipo de punto
lty = 1, # Tipo de línea
cex = 0.7) # Tamaño de texto
### 4.2 Diagrama de caja (Boxplot)
boxplot(api_be,
horizontal = TRUE, # Horizontal (como el ejemplo)
col = "blue",
main = "Gráfica: Distribución de Api_BE\n(Campo Sacha)",
xlab = "Api_BE",
notch = FALSE) # Sin muesca
## 5: Resumen y outliers
# Resumen
summary(api_be)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 20.70 25.10 24.72 27.90 37.60
# Identificar outliers
outliers <- boxplot.stats(api_be)$out
num_outliers <- length(outliers)
min_outliers <- min(outliers)
max_outliers <- max(outliers)
cat("Número de outliers:", num_outliers, "\n")
## Número de outliers: 6
if(num_outliers > 0) {
cat("Mínimo outlier:", min_outliers, "\n")
cat("Máximo outlier:", max_outliers, "\n")
}
## Mínimo outlier: 0
## Máximo outlier: 5
# Media aritmética
x <- mean(api_be)
# Mediana
Me <- median(api_be)
# Mínimo y máximo
ri <- min(api_be)
rs <- max(api_be)
# Mostrar resultados
cat("Media aritmética (x) =", x, "\n")
## Media aritmética (x) = 24.72485
cat("Mediana (Me) =", Me, "\n")
## Mediana (Me) = 25.1
cat("Mínimo (ri) =", ri, "\n")
## Mínimo (ri) = 0
cat("Máximo (rs) =", rs, "\n")
## Máximo (rs) = 37.6
# Varianza
varianza <- var(api_be)
cat("Varianza =", varianza, "\n")
## Varianza = 18.07387
# Desviación estándar
s <- sd(api_be)
cat("Desviación estándar (s) =", s, "\n")
## Desviación estándar (s) = 4.251337
# Coeficiente de variación
CV <- (s / x) * 100
cat("Coeficiente de variación (CV) =", CV, "%\n")
## Coeficiente de variación (CV) = 17.19459 %
# 5.3 Forma
# install.packages("e1071")
library(e1071)
# Coeficiente de asimetría
As <- skewness(api_be)
# Coeficiente de kurtosis
k <- kurtosis(api_be)
cat("Coeficiente de asimetría =", As, "\n")
## Coeficiente de asimetría = -0.1674964
cat("Coeficiente de kurtosis =", k, "\n")
## Coeficiente de kurtosis = -0.07633838
# 6 Tabla resumen
Variable <- c("Api_BE")
TablaIndicadores <- data.frame(
Variable,
ri, # mínimo
rs, # máximo
round(x, 2), # media (x)
Me, # mediana (Me)
round(s, 2), # desviación estándar (sd)
round(CV, 2), # coeficiente de variación (%)
round(As, 2), # asimetría (As)
round(k, 2) # kurtosis (K)
)
colnames(TablaIndicadores) <- c("Variable", "minimo", "máximo", "x",
"Me", "sd", "Cv (%)", "As", "K")
library(gt)
tabla_resumen_gt <- TablaIndicadores %>%
gt() %>%
tab_header(
title = md("*Tabla: Indicadores estadísticos*"),
subtitle = md("**Variable: Api_BE**")
) %>%
tab_source_note(
source_note = md("Campo Sacha")
) %>%
tab_options(
table.border.top.color = "black",
table.border.bottom.color = "black",
heading.border.bottom.color = "black",
heading.border.bottom.width = px(2)
) %>%
# Formatear números (2 decimales)
fmt_number(
columns = c("minimo", "máximo", "x", "Me", "sd", "Cv (%)", "As", "K"),
decimals = 2
) %>%
# Añadir % al CV
fmt_number(
columns = "Cv (%)",
pattern = "{x}%"
)
# Mostrar tabla
tabla_resumen_gt
| Tabla: Indicadores estadísticos | ||||||||
| Variable: Api_BE | ||||||||
| Variable | minimo | máximo | x | Me | sd | Cv (%) | As | K |
|---|---|---|---|---|---|---|---|---|
| Api_BE | 0.00 | 37.60 | 24.72 | 25.10 | 4.25 | 17.19% | −0.17 | −0.08 |
| Campo Sacha | ||||||||
# 1. Crear tabla
TablaOutliers <- data.frame(
Outliers = num_outliers,
Mínimo = ifelse(num_outliers > 0, min_outliers, NA),
Máximo = ifelse(num_outliers > 0, max_outliers, NA)
)
library(gt)
tabla_outliers_final <- TablaOutliers %>%
gt() %>%
tab_header(
title = "Outliers - Api_BE",
subtitle = "Campo Sacha"
)
# 3. Mostrar
tabla_outliers_final
| Outliers - Api_BE | ||
| Campo Sacha | ||
| Outliers | Mínimo | Máximo |
|---|---|---|
| 6 | 0 | 5 |
#La variable Api_BE en Campo Sacha opera de manera muy estable y predecible, con un valor típico alrededor de 25 (media 24.72) y poca variación (solo 17.19%). Su comportamiento es casi perfectamente simétrico y normal, y de todas las mediciones, solo 6 valores fueron excepcionalmente bajos (entre 0 y 5). Esto confirma que es un proceso bien controlado y confiable.