setwd("/cloud/project/")
datos<-read.csv("DerramesEEUU.csv", header = TRUE, sep=";" , dec=",")
str(datos)
## 'data.frame': 2760 obs. of 59 variables:
## $ NumeroInforme : int 20100064 20100054 20100092 20100098 20100101 20100102 20100113 20100120 20100039 20100150 ...
## $ NumeroComplementario : int 15072 15114 15120 15127 15130 15132 15146 15162 15197 15205 ...
## $ DiaAccidente : int 8 25 10 28 27 29 11 23 15 11 ...
## $ MesAccidente : int 4 3 5 4 5 5 6 5 3 1 ...
## $ AnioAccidente : int 2010 2010 2010 2010 2010 2010 2010 2010 2010 2010 ...
## $ HoraAccidente : int 6 13 6 24 3 14 7 6 15 2 ...
## $ AmPmAccidente : chr "a. m." "p. m." "a. m." "p. m." ...
## $ IDOperador : int 31684 18779 30829 12105 20160 30003 1248 300 18718 32296 ...
## $ NombreOperador : chr "CONOCOPHILLIPS" "SUNOCO, INC (R&M)" "TEPPCO CRUDE PIPELINE, LLC" "MAGELLAN AMMONIA PIPELINE, L.P." ...
## $ NombreOleoductoInstalacion : chr "GD-03, GOLD LINE" "PHILADELPHIA REFINERY - WEST YARD" "HOBBS TO MIDLAND" "WHITING TO EARLY SEGMENT" ...
## $ UbicacionOleoducto : chr "ONSHORE" "ONSHORE" "ONSHORE" "ONSHORE" ...
## $ TipoOleoducto : chr "ABOVEGROUND" "ABOVEGROUND" "UNDERGROUND" "UNDERGROUND" ...
## $ TipoLiquido : chr "REFINED AND/OR PETROLEUM PRODUCT (NON-HVL), LIQUID" "REFINED AND/OR PETROLEUM PRODUCT (NON-HVL), LIQUID" "CRUDE OIL" "HVL OR OTHER FLAMMABLE OR TOXIC FLUID, GAS" ...
## $ SubtipoLiquido : chr "GASOLINE (NON-ETHANOL)" "OTHER" "-" "ANHYDROUS AMMONIA" ...
## $ NombreLiquido : chr "-" "VACUUM GAS OIL (VGO)" "-" "-" ...
## $ CiudadAccidente : chr "GREEN RIDGE" "PHILADELPHIA" "HOBBS" "SCHALLER" ...
## $ CondadoAccidente : chr "PETTIS" "PHILADELPHIA" "LEA" "IDA" ...
## $ EstadoAccidente : chr "MO" "PA" "NM" "IA" ...
## $ LatitudAccidente : num 38.6 39.9 32.6 42.5 30.2 ...
## $ LongitudAccidente : num -93.4 -75.2 -103.1 -95.3 -91.2 ...
## $ CategoriaCausa : chr "NATURAL FORCE DAMAGE" "MATERIAL/WELD/EQUIP FAILURE" "CORROSION" "MATERIAL/WELD/EQUIP FAILURE" ...
## $ SubcategoriaCausa : chr "TEMPERATURE" "NON-THREADED CONNECTION FAILURE" "EXTERNAL" "CONSTRUCTION, INSTALLATION OR FABRICATION-RELATED" ...
## $ LiberacionInvoluntariaBarriles : num 0.24 1700 2 0.36 1.31 ...
## $ LiberacionIntencionalBarriles : chr "0" "0" "-" "0.05" ...
## $ RecuperacionLiquidoBarriles : num 0.07 1699 0.48 0 0 ...
## $ PerdidaNetaBarriles : num 0.17 1 1.52 0.36 1.31 ...
## $ IgnicionLiquido : chr "NO" "NO" "NO" "NO" ...
## $ ExplosionLiquido : chr "NO" "NO" "NO" "NO" ...
## $ CierreOleoducto : chr "YES" "YES" "NO" "NO" ...
## $ DiaCierre : chr "8" "25" "-" "-" ...
## $ MesCierre : chr "4" "3" "-" "-" ...
## $ AnioCierre : chr "2010" "2010" "-" "-" ...
## $ HoraCierre : chr "6" "18" "-" "-" ...
## $ AmPmCierre : chr "a. m." "p. m." "-" "-" ...
## $ DiaReinicio : chr "9" "28" "-" "-" ...
## $ MesReinicio : chr "4" "3" "-" "-" ...
## $ AnioReinicio : chr "2010" "2010" "-" "-" ...
## $ HoraReinicio : chr "10" "16" "-" "-" ...
## $ AmPmReinicio : chr "a. m." "p. m." "-" "-" ...
## $ EvacuacionesPublicas : chr "-" "0" "-" "-" ...
## $ LesionesEmpleadosOperador : chr "-" "-" "-" "-" ...
## $ LesionesContratistasOperador : chr "-" "-" "-" "-" ...
## $ LesionesRescatistasEmergencia : chr "-" "-" "-" "-" ...
## $ OtrasLesiones : chr "-" "-" "-" "-" ...
## $ LesionesPublico : chr "-" "-" "-" "-" ...
## $ TodasLesiones : chr "-" "-" "-" "-" ...
## $ FallecimientosEmpleadosOperador : chr "-" "-" "-" "-" ...
## $ FallecimientosContratistasOperador : chr "-" "-" "-" "-" ...
## $ FallecimientosRescatistasEmergencia : chr "-" "-" "-" "-" ...
## $ OtrosFallecimientos : chr "-" "-" "-" "-" ...
## $ FallecimientosPublico : chr "-" "-" "-" "-" ...
## $ TodosFallecimientos : chr "-" "-" "-" "-" ...
## $ CostosDaniosPropiedad : chr "0" "0" "30000" "12000" ...
## $ CostosMercanciaPerdidas : chr "27" "0" "100" "30" ...
## $ CostosDaniosPropiedadesPublicasPrivadas: chr "0" "0" "1000" "5000" ...
## $ CostosRespuestaEmergencia : chr "0" "0" "-" "0" ...
## $ CostosRemediacionAmbiental : chr "0" "100000" "20000" "15000" ...
## $ OtrosCostos : chr "0" "0" "-" "0" ...
## $ TodosCostos : int 27 100000 51100 32030 5220 150 7500 9965 11497 165593 ...
tabla_Longitud <- data.frame(
liminf = round(liminf, 3),
limsup = round(limsup, 3),
MC = round(MC, 3),
ni = ni,
hi_porc = round(hi, 3),
Ni_asc = Niasc,
Ni_dsc = Nidsc,
Hiasc_porc = round(Hiasc, 3),
Hidsc_porc = round(Hidsc, 3)
)
total_ni <- sum(tabla_Longitud$ni)
total_hi <- 100
TDFLongitudCompleto <- rbind(tabla_Longitud, data.frame(
liminf = "TOTAL",
limsup = " ",
MC = " ",
ni = total_ni,
hi_porc = total_hi,
Ni_asc = " ",
Ni_dsc = " ",
Hiasc_porc = " ",
Hidsc_porc = " "
))
library(gt)
tabla_longitud_gt <- TDFLongitudCompleto %>%
gt() %>%
cols_label(
liminf = md("**liminf**"),
limsup = md("**limsup**"),
MC = md("**MC**"),
ni = md("**ni**"),
hi_porc = md("**hi (%)**"),
Ni_asc = md("**Ni ↑**"),
Ni_dsc = md("**Ni ↓**"),
Hiasc_porc = md("**Hi ↑ (%)**"),
Hidsc_porc = md("**Hi ↓ (%)**")
) %>%
tab_header(
title = md("**Tabla N° 1**"),
subtitle = md("**Distribución de frecuencias de la Longitud de
accidentes ocurridos en EE.UU (2010-2017)**")
) %>%
tab_source_note(
source_note = md("Autor: Grupo 1")
) %>%
tab_options(
table.background.color = "white",
row.striping.background_color = "white",
table.border.top.color = "black",
table.border.bottom.color = "black",
table.border.top.style = "solid",
table.border.bottom.style = "solid",
column_labels.border.top.color = "black",
column_labels.border.bottom.color = "black",
column_labels.border.bottom.width = px(2),
heading.border.bottom.color = "black",
heading.border.bottom.width = px(2),
table_body.hlines.color = "gray",
table_body.border.bottom.color = "black"
) %>%
tab_style(
style = cell_text(weight = "bold"),
locations = cells_body(
rows = liminf == "TOTAL"
)
)
tabla_longitud_gt
Tabla N° 1 | ||||||||
Distribución de frecuencias de la Longitud de accidentes ocurridos en EE.UU (2010-2017) | ||||||||
liminf | limsup | MC | ni | hi (%) | Ni ↑ | Ni ↓ | Hi ↑ (%) | Hi ↓ (%) |
---|---|---|---|---|---|---|---|---|
-158.1 | -150.799 | -154.45 | 3 | 0.109 | 3 | 2760 | 0.109 | 100 |
-150.799 | -143.499 | -147.149 | 11 | 0.399 | 14 | 2757 | 0.508 | 99.891 |
-143.499 | -136.198 | -139.849 | 0 | 0.000 | 14 | 2746 | 0.508 | 99.492 |
-136.198 | -128.898 | -132.548 | 0 | 0.000 | 14 | 2746 | 0.508 | 99.492 |
-128.898 | -121.597 | -125.247 | 26 | 0.942 | 40 | 2746 | 1.45 | 99.492 |
-121.597 | -114.297 | -117.947 | 138 | 5.000 | 178 | 2720 | 6.45 | 98.55 |
-114.297 | -106.996 | -110.646 | 65 | 2.355 | 243 | 2582 | 8.805 | 93.55 |
-106.996 | -99.696 | -103.346 | 479 | 17.355 | 722 | 2517 | 26.16 | 91.195 |
-99.696 | -92.395 | -96.045 | 1264 | 45.797 | 1986 | 2038 | 71.957 | 73.84 |
-92.395 | -85.094 | -88.745 | 429 | 15.543 | 2415 | 774 | 87.5 | 28.043 |
-85.094 | -77.794 | -81.444 | 160 | 5.797 | 2575 | 345 | 93.297 | 12.5 |
-77.794 | -70.493 | -74.144 | 185 | 6.703 | 2760 | 185 | 100 | 6.703 |
TOTAL | 2760 | 100.000 | ||||||
Autor: Grupo 1 |
histoLongitud <- hist(Longitud,
main ="Distribución de frecuencias de la Longitud de
accidentes en oleoductos ocurridos en EE.UU.",
xlab = "Longitud (°)",
ylab = "Frecuencia",
col = "pink",
border = "black")
## [1] -160 -155 -150 -145 -140 -135 -130 -125 -120 -115 -110 -105 -100 -95 -90
## [16] -85 -80 -75 -70
TDFLongitudR <- data.frame(LimInf, LimSup, MC, ni, hi = round(hi,3),
Niasc, Nidsc, Hiasc, Hidsc)
total_ni <- sum(ni)
total_hi <- 100
TDFLongitudRFinal <- rbind(TDFLongitudR,
data.frame(LimInf="Total",
LimSup=" ",
MC=" ",
ni=total_ni,
hi=total_hi,
Niasc=" ",
Nidsc=" ",
Hiasc=" ",
Hidsc=" "))
tabla_LongitudR_gt <- TDFLongitudRFinal %>%
gt() %>%
cols_label(
LimInf = md("**LimInf**"),
LimSup = md("**LimSup**"),
MC = md("**MC**"),
ni = md("**ni**"),
hi = md("**hi (%)**"),
Niasc = md("**Ni ↑**"),
Nidsc = md("**Ni ↓**"),
Hiasc = md("**Hi ↑ (%)**"),
Hidsc = md("**Hi ↓ (%)**")
) %>%
tab_header(
title = md("**Tabla N° 2**"),
subtitle = md("**Distribución de frecuencias de la Longitud de
accidentes ocurridos en EE.UU (2010-2017)**")
) %>%
tab_source_note(
source_note = md("Autor: Grupo 1")
) %>%
tab_options(
table.background.color = "white",
row.striping.background_color = "white",
table.border.top.color = "black",
table.border.bottom.color = "black",
table.border.top.style = "solid",
table.border.bottom.style = "solid",
column_labels.border.top.color = "black",
column_labels.border.bottom.color = "black",
column_labels.border.bottom.width = px(2),
heading.border.bottom.color = "black",
heading.border.bottom.width = px(2),
table_body.hlines.color = "gray",
table_body.border.bottom.color = "black"
) %>%
tab_style(
style = cell_text(weight = "bold"),
locations = cells_body(
rows = LimInf == "Total"
)
)
tabla_LongitudR_gt
Tabla N° 2 | ||||||||
Distribución de frecuencias de la Longitud de accidentes ocurridos en EE.UU (2010-2017) | ||||||||
LimInf | LimSup | MC | ni | hi (%) | Ni ↑ | Ni ↓ | Hi ↑ (%) | Hi ↓ (%) |
---|---|---|---|---|---|---|---|---|
-160 | -155 | -157.5 | 3 | 0.109 | 3 | 2760 | 0.109 | 100 |
-155 | -150 | -152.5 | 1 | 0.036 | 4 | 2757 | 0.145 | 99.891 |
-150 | -145 | -147.5 | 10 | 0.362 | 14 | 2756 | 0.507 | 99.855 |
-145 | -140 | -142.5 | 0 | 0.000 | 14 | 2746 | 0.507 | 99.493 |
-140 | -135 | -137.5 | 0 | 0.000 | 14 | 2746 | 0.507 | 99.493 |
-135 | -130 | -132.5 | 0 | 0.000 | 14 | 2746 | 0.507 | 99.493 |
-130 | -125 | -127.5 | 0 | 0.000 | 14 | 2746 | 0.507 | 99.493 |
-125 | -120 | -122.5 | 45 | 1.630 | 59 | 2746 | 2.138 | 99.493 |
-120 | -115 | -117.5 | 118 | 4.275 | 177 | 2701 | 6.413 | 97.862 |
-115 | -110 | -112.5 | 23 | 0.833 | 200 | 2583 | 7.246 | 93.587 |
-110 | -105 | -107.5 | 71 | 2.572 | 271 | 2560 | 9.819 | 92.754 |
-105 | -100 | -102.5 | 438 | 15.870 | 709 | 2489 | 25.688 | 90.181 |
-100 | -95 | -97.5 | 889 | 32.210 | 1598 | 2051 | 57.899 | 74.312 |
-95 | -90 | -92.5 | 576 | 20.870 | 2174 | 1162 | 78.768 | 42.101 |
-90 | -85 | -87.5 | 241 | 8.732 | 2415 | 586 | 87.5 | 21.232 |
-85 | -80 | -82.5 | 136 | 4.928 | 2551 | 345 | 92.428 | 12.5 |
-80 | -75 | -77.5 | 89 | 3.225 | 2640 | 209 | 95.652 | 7.572 |
-75 | -70 | -72.5 | 120 | 4.348 | 2760 | 120 | 100 | 4.348 |
Total | 2760 | 100.000 | ||||||
Autor: Grupo 1 |
A continuación, las gráficas de histogramas se presentan con escalas
local y global: la escala local ajusta el eje Y al valor máximo de la
categoría más alta, mientras que la escala global fija el eje Y a un
límite total, mostrando cada categoría en relación al conjunto
completo.
barplot(hi,space = 0,
main = "Gráfica N°3: Distribución porcentual de la
Longitud de accidentes en oleoductos ocurridos en EE.UU.",
col="mistyrose3",
ylab = "Porcentaje (%)",
las = 2,
axis.lty = 1.5,
cex.names = 0.9,
names.arg =TDFLongitudR$MC)
mtext("Longitud (°)", side = 1, line = 3.5, cex = 1)
barplot(hi,space = 0,
main="Gráfica N°4: Distribución porcentual de la
Longitud de accidentes en oleoductos ocurridos en EE.UU.",
col="mistyrose4",
ylab = "Porcentaje (%)",
names.arg =TDFLongitudR$MC,
las = 2,
cex.names = 0.9,
axis.lty = 1.5,
ylim = c(0,100))
mtext("Longitud (°)", side = 1, line = 3.5, cex = 1)
plot(TDFLongitudR$LimInf, TDFLongitudR$Nidsc,
main = "Gráfica N°5: Ojivas combinadas de la Longitud
de accidentes en oleoductos ocurridos en EE.UU.",
xlab = "Longitud (°)",
ylab = "Cantidad",
las = 1,
col = "skyblue",
type = "b")
lines(TDFLongitudR$LimSup, TDFLongitudR$Niasc, col = "pink", type = "b")
legend("right",
legend = c("Ojiva descendente", "Ojiva ascendente"),
col = c("skyblue", "pink"),
pch = 1,
lty = 1,
cex = 0.7)
plot(TDFLongitudR$LimInf,TDFLongitudR$Hidsc,
main = "Gráfica N°6: Ojivas combinadas de la Longitud
de accidentes en oleoductos ocurridos en EE.UU.",
xlab = "Longitud (°)",
ylab="Porcentaje (%)",
col="skyblue3",
las = 1,
type = "b")
lines(TDFLongitudR$LimSup,TDFLongitudR$Hiasc,col="pink4",type = "b")
legend("right",legend = c("Ojiva descendente", "Ojiva ascendente"),
col = c("skyblue3", "pink4"),
pch = 1, lty = 1,cex = 0.7)
boxplot(Longitud, horizontal = TRUE, col = "pink3",
main = "Gráfica No.7: Distribución de la Longitud de
accidentes en oleoductos ocurridos en EE.UU.",
xlab = "Longitud (°)",
xaxt = "n")
axis(1, at = pretty(Longitud), labels = format(pretty(Longitud), scientific = FALSE))
library(gt)
Variable <- c("Longitud")
Tabla_indicadores_Longitud <- data.frame(
Variable,
ri = round(ri, 3),
rs = round(rs, 3),
media_aritmetica = round(media_aritmetica, 3),
mediana = round(mediana, 3),
Mo,
S = round(desviacion_estandar, 3),
`Cv (%)` = round(coeficiente_variabilidad, 3),
As = round(As, 3),
K = round(curtosis, 3)
)
colnames(Tabla_indicadores_Longitud) <- c("Variable","Mínimo",
"Máximo","x",
"Me","Mo",
"S","Cv (%)",
"As","K")
tabla_indicadores_gt <- Tabla_indicadores_Longitud %>%
gt() %>%
tab_header(
title = md("**Tabla N°3**"),
subtitle = md("**Indicadores estadísticos de la variable Longitud de
accidentes ocurridos en EE.UU (2010-2017)**")
) %>%
tab_source_note(
source_note = md("Autor: Grupo 1")
) %>%
tab_options(
table.background.color = "white",
row.striping.background_color = "white",
table.border.top.color = "black",
table.border.bottom.color = "black",
table.border.top.style = "solid",
table.border.bottom.style = "solid",
column_labels.font.weight = "bold",
column_labels.border.top.color = "black",
column_labels.border.bottom.color = "black",
column_labels.border.bottom.width = px(2),
heading.border.bottom.color = "black",
heading.border.bottom.width = px(2),
table_body.hlines.color = "gray",
table_body.border.bottom.color = "black"
)
tabla_indicadores_gt
Tabla N°3 | |||||||||
Indicadores estadísticos de la variable Longitud de accidentes ocurridos en EE.UU (2010-2017) | |||||||||
Variable | Mínimo | Máximo | x | Me | Mo | S | Cv (%) | As | K |
---|---|---|---|---|---|---|---|---|---|
Longitud | -158.1 | -70.493 | -95.923 | -95.628 | [-99.696,-92.395) | 10.479 | -10.925 | -0.78 | 3.797 |
Autor: Grupo 1 |
Tabla_outliers_Longitud <- data.frame(
Outliers = num_outliers,
Mínimo = minimooutliers,
Máximo = maximooutliers
)
library(gt)
Tabla_outliers_Longitud %>%
gt() %>%
tab_header(
title = md("**Tabla N°4**"),
subtitle = md("**Valores atípicos de la variable Longitud
de accidentes ocurridos en EE.UU (2010-2017)**")
) %>%
tab_options(
table.border.top.color = "black",
table.border.bottom.color = "black",
table.border.top.style = "solid",
table.border.bottom.style = "solid",
column_labels.font.weight = "bold",
column_labels.border.top.color = "black",
column_labels.border.bottom.color = "black",
column_labels.border.bottom.width = px(2),
heading.border.bottom.color = "black",
heading.border.bottom.width = px(2),
table_body.hlines.color = "grey",
table_body.border.bottom.color = "black"
)
Tabla N°4 | ||
Valores atípicos de la variable Longitud de accidentes ocurridos en EE.UU (2010-2017) | ||
Outliers | Mínimo | Máximo |
---|---|---|
347 | -158.0999 | -70.49336 |
La variable longitud de los accidentes ocurridos en EE.UU. fluctúa
entre -158.1° y -70.493°, con una media de -95.923° y una desviación
estándar de 10.479°, lo que muestra un conjunto de datos relativamente
heterogéneo y con cierta dispersión longitudinal. Los valores se
concentran principalmente en la franja central del país, cercana a los
-95°, y presentan un sesgo negativo que refleja una ligera acumulación
de accidentes hacia el occidente. Asimismo, la curtosis superior a 3
indica una distribución leptocúrtica, con concentración en torno a la
media pero con colas pronunciadas. Se identificaron 347 valores
atípicos, localizados principalmente hacia las longitudes extremas
(-158.0999°, correspondiente a Hawái, y -70.493°, cercano a la costa
este). Por lo antes expuesto, el comportamiento de la variable resulta
coherente con la extensión geográfica de EE.UU., ya que la mayoría de
los accidentes se concentran en el territorio continental,
diferenciándose de casos aislados en regiones periféricas como Hawái y
la costa atlántica.