2. TABLA DE DISTRIBUCION CON STURGES
# STURGES
k <- floor(1 + 3.322 * log10(n))
minimo <- min(longitud)
maximo <- max(longitud)
R <- maximo - minimo
A <- R/k
# LIMITES
Li <- round(seq(minimo, maximo-A, by=A),2)
Ls <- round(seq(minimo+A, maximo, by=A),2)
MC <- round((Li+Ls)/2,2)
# FRECUENCIAS
ni <- numeric(length(Li))
for(i in 1:length(Li)){
ni[i] <- sum(longitud >= Li[i] & longitud < Ls[i])
}
ni[length(Li)] <- sum(longitud >= Li[length(Li)] & longitud <= maximo)
hi <- (ni/sum(ni))*100
Niasc <- cumsum(ni)
Nidsc <- rev(cumsum(rev(ni)))
Hiasc <- round(cumsum(hi),2)
Hidsc <- round(rev(cumsum(rev(hi))),2)
# TABLA FINAL
TDFlongitud <- round(data.frame(Li, Ls, MC, ni, hi, Niasc, Nidsc, Hiasc, Hidsc),2)
fila_total <- data.frame(Li = "TOTAL", Ls = "", MC = "", ni = sum(TDFlongitud$ni),
hi = round(sum(TDFlongitud$hi),2), Niasc = "", Nidsc = "",
Hiasc = "", Hidsc = "")
TDFlongitud_p <- rbind(TDFlongitud, fila_total)
# TABLA GT
TDFlongitud_p %>%
gt() %>%
tab_header(title = md("*Tabla Nº:1*"), subtitle = md("Tabla de distribución de la longitud de los pozos (Sturges)")) %>%
tab_source_note(source_note = md("Autor: KATHERINE FERNANDA SINGO CARDENAS")) %>%
tab_options(table.border.top.color = "black", table.border.bottom.color = "black",
column_labels.border.bottom.width = px(2), row.striping.include_table_body = TRUE)
| Tabla Nº:1 |
| Tabla de distribución de la longitud de los pozos (Sturges) |
| Li |
Ls |
MC |
ni |
hi |
Niasc |
Nidsc |
Hiasc |
Hidsc |
| -108.4 |
-108.02 |
-108.21 |
1487 |
11.84 |
1487 |
12560 |
11.84 |
100 |
| -108.02 |
-107.64 |
-107.83 |
3058 |
24.35 |
4545 |
11073 |
36.19 |
88.16 |
| -107.64 |
-107.26 |
-107.45 |
3230 |
25.72 |
7775 |
8015 |
61.9 |
63.81 |
| -107.26 |
-106.88 |
-107.07 |
853 |
6.79 |
8628 |
4785 |
68.69 |
38.1 |
| -106.88 |
-106.5 |
-106.69 |
0 |
0.00 |
8628 |
3932 |
68.69 |
31.31 |
| -106.5 |
-106.12 |
-106.31 |
0 |
0.00 |
8628 |
3932 |
68.69 |
31.31 |
| -106.12 |
-105.74 |
-105.93 |
0 |
0.00 |
8628 |
3932 |
68.69 |
31.31 |
| -105.74 |
-105.36 |
-105.55 |
0 |
0.00 |
8628 |
3932 |
68.69 |
31.31 |
| -105.36 |
-104.97 |
-105.16 |
211 |
1.68 |
8839 |
3932 |
70.37 |
31.31 |
| -104.97 |
-104.59 |
-104.78 |
599 |
4.77 |
9438 |
3721 |
75.14 |
29.63 |
| -104.59 |
-104.21 |
-104.4 |
1197 |
9.53 |
10635 |
3122 |
84.67 |
24.86 |
| -104.21 |
-103.83 |
-104.02 |
822 |
6.54 |
11457 |
1925 |
91.22 |
15.33 |
| -103.83 |
-103.45 |
-103.64 |
352 |
2.80 |
11809 |
1103 |
94.02 |
8.78 |
| -103.45 |
-103.07 |
-103.26 |
751 |
5.98 |
12560 |
751 |
100 |
5.98 |
| TOTAL |
|
|
12560 |
100.00 |
|
|
|
|
| Autor: KATHERINE FERNANDA SINGO CARDENAS |
2. TABLA DE DISTRIBUCION AGRUPADA
histograma_longitud <- hist(longitud, plot = FALSE)
lis <- histograma_longitud$breaks[1:(length(histograma_longitud$breaks)-1)]
lss <- histograma_longitud$breaks[2:length(histograma_longitud$breaks)]
MC_f <- histograma_longitud$mids
ni_f <- histograma_longitud$counts
hi_f <- (ni_f/sum(ni_f))*100
Niasc_f <- cumsum(ni_f)
Nidsc_f <- rev(cumsum(rev(ni_f)))
Hiasc_f <- round(cumsum(hi_f), 2)
Hidsc_f <- round(rev(cumsum(rev(hi_f))), 2)
TDFlongitud_f <- round(data.frame(lis, lss, MC_f, ni_f, hi_f, Niasc_f, Nidsc_f, Hiasc_f, Hidsc_f),2)
fila_total_f <- data.frame(lis = "TOTAL", lss = "", MC_f = "", ni_f = sum(TDFlongitud_f$ni_f),
hi_f = round(sum(TDFlongitud_f$hi_f),2), Niasc_f = "",
Nidsc_f = "", Hiasc_f = "", Hidsc_f = "")
TDFlongitud_t <- rbind(TDFlongitud_f, fila_total_f)
TDFlongitud_t %>%
gt() %>%
tab_header(title = md("*Tabla Nº:2*"), subtitle = md("Tabla de distribución simplificada de la longitud")) %>%
tab_source_note(source_note = md("Autor: KATHERINE FERNANDA SINGO CARDENAS")) %>%
tab_options(table.border.top.color = "black", table.border.bottom.color = "black",
row.striping.include_table_body = TRUE)
| Tabla Nº:2 |
| Tabla de distribución simplificada de la longitud |
| lis |
lss |
MC_f |
ni_f |
hi_f |
Niasc_f |
Nidsc_f |
Hiasc_f |
Hidsc_f |
| -108.5 |
-108 |
-108.25 |
1630 |
12.98 |
1630 |
12561 |
12.98 |
100 |
| -108 |
-107.5 |
-107.75 |
4010 |
31.92 |
5640 |
10931 |
44.9 |
87.02 |
| -107.5 |
-107 |
-107.25 |
2972 |
23.66 |
8612 |
6921 |
68.56 |
55.1 |
| -107 |
-106.5 |
-106.75 |
17 |
0.14 |
8629 |
3949 |
68.7 |
31.44 |
| -106.5 |
-106 |
-106.25 |
0 |
0.00 |
8629 |
3932 |
68.7 |
31.3 |
| -106 |
-105.5 |
-105.75 |
0 |
0.00 |
8629 |
3932 |
68.7 |
31.3 |
| -105.5 |
-105 |
-105.25 |
171 |
1.36 |
8800 |
3932 |
70.06 |
31.3 |
| -105 |
-104.5 |
-104.75 |
804 |
6.40 |
9604 |
3761 |
76.46 |
29.94 |
| -104.5 |
-104 |
-104.25 |
1690 |
13.45 |
11294 |
2957 |
89.91 |
23.54 |
| -104 |
-103.5 |
-103.75 |
453 |
3.61 |
11747 |
1267 |
93.52 |
10.09 |
| -103.5 |
-103 |
-103.25 |
814 |
6.48 |
12561 |
814 |
100 |
6.48 |
| TOTAL |
|
|
12561 |
100.00 |
|
|
|
|
| Autor: KATHERINE FERNANDA SINGO CARDENAS |
3. GRAFICAS DE DISTRIBUCION
par(mar = c(6, 5, 4, 2) + 0.1)
colores <- gray.colors(length(ni_f), start = 0.3, end = 0.9)
color_abs <- "#76D7C4"
color_rel <- "#F1948A"
# Grafica 1: Histograma Cantidad
hist(longitud, col = "gray", xlab = "Longitud del pozo (Longitude of well pad)",
ylab = "Cantidad", main = "Gráfica Nº1: Distribución de la longitud de los pozos de gas natural")

# Grafica 2: Colores
hist(longitud, col = colores, xlab = "Longitud del pozo (Longitude of well pad)",
ylab = "Cantidad", main = "Gráfica Nº2: Distribución de la longitud de los pozos de gas natural")

# Grafica 3: Global ni
hist(longitud, col = colores, xlab = "Longitud del pozo (Longitude of well pad)",
ylab = "Cantidad", ylim = c(0, max(ni_f) + 5),
main = "Gráfica Nº3: Distribución de la longitud de los pozos de gas natural")

# Grafica 4: Local hi
breaks_long <- seq(from = floor(min(longitud)), to = ceiling(max(longitud)), by = 1)
etiquetas_x <- breaks_long[-1]
barplot(hi_f, names.arg = etiquetas_x[1:length(hi_f)], col = color_abs, ylim = c(0, max(hi_f) + 5),
space = 0, cex.names = 0.6, ylab = "Porcentaje (%)", xlab = "Longitude of well pad",
main = "Gráfica Nº4: Distribución porcentual de la longitud de los pozos")

# Grafica 5: Global hi
barplot(hi_f, names.arg = etiquetas_x[1:length(hi_f)], col = color_rel, ylim = c(0, 100),
space = 0, cex.names = 0.6, ylab = "Porcentaje (%)", xlab = "Longitud del pozo",
main = "Gráfica Nº5: Distribución porcentual de la longitud")

# Grafica 6: Boxplot
boxplot(longitud, horizontal = TRUE, col = colores, xlab = "Longitud del pozo",
main = "Gráfica Nº6: Distribución de la longitud de los pozos de gas natural")

# Grafica 7: Ojiva Ni
plot(lss, Nidsc_f, type="o", col="blue", pch=19, xlab="Longitud del pozo",
ylab="Cantidad acumulada", main="Gráfica Nº7: Ojiva combinada de la longitud (Ni)")
lines(lis, Niasc_f, col="black", type="b", pch=18)

# Grafica 8: Ojiva Hi
plot(lss, Hidsc_f, type="o", col="blue", pch=19, xlab="Longitud del pozo",
ylab="Porcentaje acumulado (%)", main="Gráfica Nº8: Ojiva combinada porcentual (Hi)")
lines(lis, Hiasc_f, col="black", type="b", pch=18)
