2. TABLA DE DISTRIBUCIÓN DE CANTIDAD
Complejidad_raw <- datos$Complexity.of.the.casing.structure
Complejidad_limpia <- Complejidad_raw[!is.na(Complejidad_raw)]
Complejidad <- factor(
Complejidad_limpia,
levels = as.character(0:7),
ordered = TRUE
)
ni <- table(Complejidad)
hi <- round(prop.table(ni) * 100, 2)
tabla_base <- data.frame(
Nivel = names(ni),
ni = as.numeric(ni),
hi = as.numeric(hi)
)
fila_total <- data.frame(
Nivel = "TOTAL",
ni = sum(tabla_base$ni),
hi = round(sum(tabla_base$hi))
)
tabla_final_comp <- rbind(tabla_base, fila_total)
tabla_gt <- tabla_final_comp %>%
gt() %>%
cols_label(
Nivel = "Nivel de Complejidad",
ni = "ni",
hi = "hi (%)"
) %>%
tab_header(
title = md("Tabla Nº 1. Distribución por nivel de complejidad del
revestimiento de los pozos de gas natural en Nuevo Mexico")
) %>%
tab_style(
style = list(
cell_fill(color = "lightgray"),
cell_text(weight = "bold")
),
locations = list(
cells_body(rows = Nivel == "TOTAL"),
cells_title(groups = "title")
)
) %>%
cols_align(
align = "center",
columns = c(ni, hi)
) %>%
tab_options(
table.width = pct(80),
heading.title.font.size = px(20),
heading.title.font.weight = "bold",
table.font.names = "Open Sans",
column_labels.font.weight = "bold"
)
tabla_gt
| Tabla Nº 1. Distribución por nivel de complejidad del
revestimiento de los pozos de gas natural en Nuevo Mexico |
| Nivel de Complejidad |
ni |
hi (%) |
| 0 |
2476 |
19.71 |
| 1 |
33 |
0.26 |
| 2 |
5383 |
42.85 |
| 3 |
4138 |
32.94 |
| 4 |
503 |
4.00 |
| 5 |
25 |
0.20 |
| 6 |
2 |
0.02 |
| 7 |
1 |
0.01 |
| TOTAL |
12561 |
100.00 |
3. GRÁFICAS DE DISTRIBUCIÓN DE CANTIDAD
par(oma = c(1, 1, 1, 1))
color_barras_abs <- "#76D7C4"
color_barras_rel <- "#F1948A"
# Gráfica Nº 1: Absoluta Local
barplot(tabla_base$ni,
main = "Gráfica Nº1: Distribución de cantidad de complejidad de
Estructura de revestimiento de los pozos de gas natural en Nuevo
Mexico",
cex.main = 1, col = color_barras_abs, border = "black",
xlab = "Nivel de Complejidad", ylab = "Cantidad (ni)",
names.arg = tabla_base$Nivel)
box(which = "outer", col = "black")

# Gráfica Nº 2: Absoluta Global
barplot(tabla_base$ni,
main = "Gráfica Nº2: Distribución de cantidad de complejidad de
Estructura de revestimiento de los pozos de gas natural en Nuevo
Mexico",
cex.main = 1, col = color_barras_abs, border = "black",
xlab = "Nivel de Complejidad", ylab = "Cantidad (ni)",
names.arg = tabla_base$Nivel, ylim = c(0, sum(tabla_base$ni)))
box(which = "outer", col = "black")

# Gráfica Nº 3: Relativa Local
barplot(tabla_base$hi,
main = "Gráfica Nº3: Distribución de cantidad en porcentaje de
complejidad de Estructura de revestimiento de los pozos de gas natural
en Nuevo Mexico
",
cex.main = 1, col = color_barras_rel, border = "black",
xlab = "Nivel de Complejidad", ylab = "Porcentaje (%)",
names.arg = tabla_base$Nivel)
box(which = "outer", col = "black")

# Gráfica Nº 4: Relativa Global
barplot(tabla_base$hi,
main = "Gráfica Nº4: Distribución de cantidad en porcentaje de
complejidad de Estructura de revestimiento de los pozos de gas
natural en Nuevo Mexico
",
cex.main = 1, col = color_barras_rel, border = "black",
xlab = "Nivel de Complejidad", ylab = "Porcentaje (%)",
names.arg = tabla_base$Nivel, ylim = c(0, 100))
box(which = "outer", col = "black")

# Gráfica Nº 5: Circular
par(mar = c(1, 3, 3, 5), xpd=TRUE)
Colores_pie <- colorRampPalette(c("#82E0AA", "#F8C471", "#BB8FCE"))
etiquetas <- paste0(format(tabla_base$hi, nsmall = 1), "%")
pie(tabla_base$hi, radius = 0.8, col = Colores_pie(nrow(tabla_base)),
labels = etiquetas,
main = "Gráfica Nº 5: Distribución de cantidad en porcentaje de complejidad
de Estructura de revestimiento de los pozos de gas natural en Nuevo Mexico",
cex.main = 1, border = "white")
legend("topright", inset = c(-0.1, 0), title = "Niveles", legend = tabla_base$Nivel,
fill = Colores_pie(nrow(tabla_base)), cex = 0.8, bty = "n")
box(which = "outer", col = "black")

4. INDICADORES ESTADISTICOS
# Cálculo de la moda
tabla_moda <- table(Complejidad)
moda_complejidad <- names(tabla_moda)[which.max(as.numeric(tabla_moda))]
moda_complejidad
## [1] "2"
# Cálculo de la mediana
Complejidad_ordenada <- sort(Complejidad)
Me <- Complejidad_ordenada[ceiling(length(Complejidad_ordenada) / 2)]
Me
## [1] 2
## Levels: 0 < 1 < 2 < 3 < 4 < 5 < 6 < 7
TablaIndicadores <- data.frame(
Variable = "Complejidad de Revestimiento",
Moda = moda_complejidad,
Mediana = as.character(Me)
)
tabla_gt_ind <- TablaIndicadores %>%
gt() %>%
tab_header(
title = md("Tabla Nº 2. Indicadores estadísticos de la variable complejidad
de Estructura de revestimiento de los pozos de gas natural en Nuevo Mexico")
) %>%
tab_style(
style = list(
cell_fill(color = "lightgray"),
cell_text(weight = "bold")
),
locations = cells_title(groups = "title")
) %>%
tab_options(
table.width = pct(80),
table.font.names = "Open Sans",
column_labels.font.weight = "bold"
) %>%
cols_align(align = "center")
tabla_gt_ind
| Tabla Nº 2. Indicadores estadísticos de la variable complejidad
de Estructura de revestimiento de los pozos de gas natural en Nuevo Mexico |
| Variable |
Moda |
Mediana |
| Complejidad de Revestimiento |
2 |
2 |