1. CARGA DE DATOS Y LIBRERÍAS
library(knitr)
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
setwd("C:/Users/HP/Documents/PROYECTO ESTADISTICA/RStudio")
datos <- read.csv("tablap.csv", header = TRUE, dec = ",", sep = ";")
2. TABLA DE DISTRIBUCION
casing_nom <- datos$Complexity.of.the.casing.structure
ni_nom <- table(casing_nom)
hi_nom <- prop.table(ni_nom) * 100
tabla_final_n <- data.frame(
Nivel = names(ni_nom),
ni = as.numeric(ni_nom),
hi = as.numeric(hi_nom)
)
fila_total_n <- data.frame(
Nivel = "TOTAL",
ni = sum(tabla_final_n$ni),
hi = sum(tabla_final_n$hi)
)
tabla_final_p <- rbind(tabla_final_n, fila_total_n)
kable(tabla_final_p, format = "markdown", caption = "Tabla N 1. Distribucion de cantidad por nivel de complejidad del revestimiento")
Tabla N 1. Distribucion de cantidad por nivel de complejidad
del revestimiento
| 0 |
2476 |
19.7118064 |
| 1 |
33 |
0.2627179 |
| 2 |
5383 |
42.8548682 |
| 3 |
4138 |
32.9432370 |
| 4 |
503 |
4.0044582 |
| 5 |
25 |
0.1990287 |
| 6 |
2 |
0.0159223 |
| 7 |
1 |
0.0079611 |
| TOTAL |
12561 |
100.0000000 |
2. TABLA DE DISTRIBUCION AGRUPADA
Complejidad <- as.character(datos$Complexity.of.the.casing.structure)
Complejidad <- Complejidad[!is.na(Complejidad)]
Complejidad <- factor(
Complejidad,
levels = as.character(0:7),
ordered = TRUE
)
ni <- table(Complejidad)
hi <- round(prop.table(ni) * 100, 2)
tabla_complejidad <- data.frame(
Nivel = names(ni),
ni = as.numeric(ni),
hi = as.numeric(hi)
)
fila_total2 <- data.frame(
Nivel = "TOTAL",
ni = sum(tabla_complejidad$ni),
hi = round(sum(tabla_complejidad$hi))
)
tabla_complejidad <- rbind(tabla_complejidad, fila_total2)
kable(tabla_complejidad, format = "markdown",
caption = "Tabla N 2. Distribucion de cantidad por nivel de complejidad del revestimiento")
Tabla N 2. Distribucion de cantidad por nivel de complejidad
del revestimiento
| 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. GRAFICAS DE DISTRIBUCION
color_barras_abs <- "#76D7C4"
color_barras_rel <- "#F1948A"
# Gráfica N 1
barplot(
tabla_complejidad$ni[1:(nrow(tabla_complejidad)-1)],
main = "Gráfica N 1: Distribución de cantidad de complejidad de revestimiento
en pozos de gas natural",
cex.main = 1.1, col = color_barras_abs, border = "white",
xlab = "Nivel de Complejidad", ylab = "Cantidad (ni)",
names.arg = tabla_complejidad$Nivel[1:(nrow(tabla_complejidad)-1)])

# Gráfica N 2
barplot(
tabla_complejidad$ni[1:(nrow(tabla_complejidad)-1)],
main = "Gráfica N 2: Distribución de cantidad de complejidad de revestimiento
en pozos de gas natural",
cex.main = 1.1, col = color_barras_abs, border = "white",
xlab = "Nivel de Complejidad", ylab = "Cantidad (ni)",
names.arg = tabla_complejidad$Nivel[1:(nrow(tabla_complejidad)-1)],
ylim = c(0, 12561))

# Gráfica N 3
hi_local <- as.numeric(tabla_complejidad$hi[1:(nrow(tabla_complejidad)-1)])
barplot(
hi_local,
main = "Gráfica N 3: Distribución de cantidad en porcentaje del nivel de complejidad de
revestimiento en pozos de gas natural",
cex.main = 1.1, col = color_barras_rel, border = "white",
xlab = "Nivel de Complejidad", ylab = "Porcentaje (%)",
names.arg = tabla_complejidad$Nivel[1:(nrow(tabla_complejidad)-1)])

# Gráfica N 4
barplot(
hi_local,
main = "Gráfica N 4: Distribución de cantidad en porcentaje del nivel de complejidad de
revestimiento en pozos de gas natural",
cex.main = 1.1, col = color_barras_rel, border = "white",
xlab = "Nivel de Complejidad", ylab = "Porcentaje (%)",
names.arg = tabla_complejidad$Nivel[1:(nrow(tabla_complejidad)-1)],
ylim = c(0, 100))

# Gráfica N 5: Diagrama Circular
hi_casing <- hi_local
niveles <- tabla_complejidad$Nivel[1:(nrow(tabla_complejidad)-1)]
Colores <- colorRampPalette(c("#82E0AA", "#F8C471", "#BB8FCE"))
etiquetas <- paste0(round(hi_casing), "%")
pie(
hi_casing,
radius = 1.0,
col = Colores(length(hi_casing)),
labels = etiquetas,
main = "Gráfica Nº 5: Distribución de cantidad en porcentaje de complejidad de
revestimiento en pozos de gas natural",
cex.main = 1.1,
border = "white"
)
legend(
"bottomright",
title = "Niveles",
legend = niveles,
fill = Colores(length(hi_casing)),
cex = 1.3,
bty = "n"
)

5. TABLA DE INDICADORES ESTADISTICOS
Variable <- c("Complejidad de Revestimiento")
TablaIndicadores <- data.frame(Variable, moda_complejidad, Mediana = as.character(Me))
colnames(TablaIndicadores) <- c("Variable", "Moda", "Mediana")
kable(TablaIndicadores, format = "markdown",
caption = "Tabla N 3. Indicadores estadisticos de la variable complejidad de revestimiento")
Tabla N 3. Indicadores estadisticos de la variable complejidad
de revestimiento
| Complejidad de Revestimiento |
2 |
2 |