# 1. LIBRERIAS Y CARGA DE DATOS
library(readxl)
library(dplyr)
library(gt)
library(readr)
setwd("C:/Users/veru2/OneDrive/Escritorio/dataset_excel")
Datos <- read.csv("Oil__Gas____Other_Regulated_Wells__Beginning_1860 (2).csv",
header = TRUE, sep = ";", dec = ",")
La variable Quad Section indica la subdivision del cuadrangulo topografico (USGS) donde se ubica el pozo. Toma 9 valores (A a la I, una cuadricula 3x3), por lo que es una variable cualitativa nominal que se analiza directamente, sin necesidad de agrupar.
Secciones <- Datos$Quad.Section
TDFSecciones <- as.data.frame(table(Secciones))
TDFSecciones <- TDFSecciones[TDFSecciones$Secciones != "", ]
TDFSecciones
## Secciones Freq
## 2 A 3201
## 3 B 4831
## 4 C 3264
## 5 D 5772
## 6 E 6156
## 7 F 4933
## 8 G 6724
## 9 H 5541
## 10 I 6093
Frecuencia absoluta (ni) y relativa porcentual (hi) de pozos por seccion, ordenadas de mayor a menor.
TDFSecciones$Freq <- as.numeric(as.character(TDFSecciones$Freq))
TDFSeccionesfinal1 <- TDFSecciones %>%
group_by(Secciones) %>%
summarise(
ni = sum(Freq),
hi = round(sum(Freq) / sum(TDFSecciones$Freq) * 100, 5)) %>%
arrange(desc(ni)) %>%
as.data.frame()
colnames(TDFSeccionesfinal1)[1] <- "Seccion"
TDFSeccionesfinal1
## Seccion ni hi
## 1 G 6724 14.45555
## 2 E 6156 13.23444
## 3 I 6093 13.09900
## 4 D 5772 12.40890
## 5 H 5541 11.91229
## 6 F 4933 10.60518
## 7 B 4831 10.38590
## 8 C 3264 7.01709
## 9 A 3201 6.88165
total_ni <- sum(TDFSeccionesfinal1$ni)
total_hi <- sum(TDFSeccionesfinal1$hi)
TDFSeccionescompleta <- rbind(TDFSeccionesfinal1,
data.frame(Seccion = "Total",
ni = total_ni,
hi = total_hi))
print(TDFSeccionescompleta)
## Seccion ni hi
## 1 G 6724 14.45555
## 2 E 6156 13.23444
## 3 I 6093 13.09900
## 4 D 5772 12.40890
## 5 H 5541 11.91229
## 6 F 4933 10.60518
## 7 B 4831 10.38590
## 8 C 3264 7.01709
## 9 A 3201 6.88165
## 10 Total 46515 100.00000
gt(TDFSeccionescompleta) %>%
tab_header(
title = md("**DISTRIBUCION DE FRECUENCIAS DE POZOS POR SECCION - NUEVA YORK**"),
subtitle = "Distribucion de pozos de petroleo y gas segun la seccion del cuadrante") %>%
fmt_number(
columns = hi,
decimals = 2) %>%
cols_align(align = "center", columns = everything()) %>%
tab_style(
style = list(cell_fill(color = "#2E4053"), cell_text(color = "white", weight = "bold")),
locations = cells_title()
) %>%
tab_style(
style = list(cell_fill(color = "#F2F3F4"), cell_text(weight = "bold", color = "#2E4053")),
locations = 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))
| DISTRIBUCION DE FRECUENCIAS DE POZOS POR SECCION - NUEVA YORK | ||
| Distribucion de pozos de petroleo y gas segun la seccion del cuadrante | ||
| Seccion | ni | hi |
|---|---|---|
| G | 6724 | 14.46 |
| E | 6156 | 13.23 |
| I | 6093 | 13.10 |
| D | 5772 | 12.41 |
| H | 5541 | 11.91 |
| F | 4933 | 10.61 |
| B | 4831 | 10.39 |
| C | 3264 | 7.02 |
| A | 3201 | 6.88 |
| Total | 46515 | 100.00 |
datos <- TDFSeccionescompleta[TDFSeccionescompleta$Seccion != "Total", ]
par(mar = c(7, 5, 4, 2) + 0.1)
bp <- barplot(datos$ni,
main = "Grafica N1: Distribucion de pozos segun su seccion en Nueva York",
ylab = "Cantidad de pozos", col = "#2E4053",
names.arg = datos$Seccion,
las = 1, cex.names = 0.9, cex.axis = 0.8, cex.main = 0.95,
ylim = c(0, max(datos$ni) * 1.15))
text(x = bp, y = datos$ni,
labels = format(datos$ni, big.mark = ","),
pos = 3, cex = 0.7, xpd = TRUE)
mtext("Seccion del cuadrante", side = 1, line = 3, cex = 0.95)
par(mar = c(7, 5, 4, 2) + 0.1)
bp <- barplot(datos$ni,
main = "Grafica N2: Cantidad de pozos segun su seccion en Nueva York",
ylab = "Cantidad de pozos", col = "#2E4053",
names.arg = datos$Seccion,
las = 1, cex.names = 0.9, cex.axis = 0.8, cex.main = 0.95,
ylim = c(0, 8000))
text(x = bp, y = datos$ni,
labels = format(datos$ni, big.mark = ","),
pos = 3, cex = 0.7, xpd = TRUE)
mtext("Seccion del cuadrante", side = 1, line = 3, cex = 0.95)
par(mar = c(7, 5, 4, 2) + 0.1)
bp <- barplot(datos$hi,
main = "Grafica N3: Distribucion en porcentaje segun su seccion en Nueva York",
ylab = "Porcentaje (%)", col = "#2E4053",
names.arg = datos$Seccion,
las = 1, cex.names = 0.9, cex.axis = 0.8, cex.main = 0.95,
ylim = c(0, max(datos$hi) * 1.15))
text(x = bp, y = datos$hi,
labels = paste0(round(datos$hi, 2), "%"),
pos = 3, cex = 0.7, xpd = TRUE)
mtext("Seccion del cuadrante", side = 1, line = 3, cex = 0.95)
par(mar = c(7, 5, 4, 2) + 0.1)
bp <- barplot(datos$hi,
main = "Grafica N4: Distribucion en porcentaje segun su seccion en Nueva York",
ylab = "Porcentaje (%)", col = "#2E4053",
names.arg = datos$Seccion,
las = 1, cex.names = 0.9, cex.axis = 0.8, cex.main = 0.95,
ylim = c(0, 100))
text(x = bp, y = datos$hi,
labels = paste0(round(datos$hi, 2), "%"),
pos = 3, cex = 0.7, xpd = TRUE)
mtext("Seccion del cuadrante", side = 1, line = 3, cex = 0.95)
par(mar = c(2, 2, 4, 9), xpd = TRUE)
colores <- c("#1B4F72", "#21618C", "#2874A6", "#2E86C1", "#3498DB",
"#5DADE2", "#85C1E9", "#AED6F1", "#D6EAF8")
colores <- colores[1:nrow(datos)]
pct <- round(datos$hi, 2)
pie(datos$ni, labels = "",
col = colores, border = "white", radius = 0.95,
init.angle = 90, clockwise = TRUE, cex.main = 0.9,
main = "Grafica N5: Distribucion porcentual por seccion")
frac <- datos$ni / sum(datos$ni)
theta <- (90 - 360 * (cumsum(frac) - frac / 2)) * pi / 180
text(0.62 * cos(theta), 0.62 * sin(theta),
labels = paste0(pct, "%"),
col = "white", cex = 0.8, font = 2)
legend(x = 1.05, y = 0.9,
legend = paste0("Seccion ", datos$Seccion, " (", pct, "%)"),
fill = colores, cex = 0.8, bty = "n", title = "Seccion")
Por tratarse de una variable cualitativa nominal, la unica medida de tendencia central aplicable es la moda (la seccion mas frecuente).
moda_seccion <- datos$Seccion[which.max(datos$ni)]
Conclusiones <- data.frame(
Variable = "Seccion del cuadrante",
`Rango [Min; Max]` = "N/A",
`Media (X)` = "N/A",
`Mediana (Me)` = "N/A",
`Moda (Mo)` = moda_seccion,
`Varianza (S2)` = "N/A",
`Desv. Est. (S)` = "N/A",
`C.V. (%)` = "N/A",
`Asimetria (As)` = "N/A",
`Curtosis (K)` = "N/A",
`Valores Atipicos` = "N/A",
check.names = FALSE
)
gt(Conclusiones) %>%
tab_header(
title = md("**CONCLUSIONES Y ESTADISTICOS**"),
subtitle = "Resumen de indicadores de ubicacion de los pozos por seccion en Nueva York") %>%
tab_source_note(source_note = "Autor: Dallyana") %>%
cols_align(align = "center", columns = everything()) %>%
tab_style(
style = list(cell_fill(color = "#2E4053"), cell_text(color = "white", weight = "bold")),
locations = cells_title()
) %>%
tab_style(
style = list(cell_fill(color = "#F2F3F4"), cell_text(weight = "bold", color = "#2E4053")),
locations = 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))
| CONCLUSIONES Y ESTADISTICOS | ||||||||||
| Resumen de indicadores de ubicacion de los pozos por seccion en Nueva York | ||||||||||
| Variable | Rango [Min; Max] | Media (X) | Mediana (Me) | Moda (Mo) | Varianza (S2) | Desv. Est. (S) | C.V. (%) | Asimetria (As) | Curtosis (K) | Valores Atipicos |
|---|---|---|---|---|---|---|---|---|---|---|
| Seccion del cuadrante | N/A | N/A | N/A | G | N/A | N/A | N/A | N/A | N/A | N/A |
| Autor: Dallyana | ||||||||||
La moda corresponde a la seccion G, que concentra la mayor cantidad de pozos (14.46%). No obstante, la distribucion entre las 9 secciones (A a la I) es bastante uniforme (entre 6.9% y 14.5%), lo cual es esperable: las secciones representan una simple subdivision espacial 3x3 del cuadrangulo topografico, sin un factor geologico que favorezca una posicion especifica dentro de la cuadricula.