setwd("/cloud/project/")
datos<-read.csv("DerramesEEUU.csv", header = TRUE, sep=";" , dec=".",na.strings ="-")
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" NA "ANHYDROUS AMMONIA" ...
## $ NombreLiquido : chr NA "VACUUM GAS OIL (VGO)" NA NA ...
## $ CiudadAccidente : chr "GREEN RIDGE" "PHILADELPHIA" "HOBBS" "SCHALLER" ...
## $ CondadoAccidente : chr "PETTIS" "PHILADELPHIA" "LEA" "IDA" ...
## $ EstadoAccidente : chr "MO" "PA" "NM" "IA" ...
## $ LatitudAccidente : chr "38,63064" "39,91934" "32,611" "42,45589" ...
## $ LongitudAccidente : chr "-93,39656" "-75,20447" "-103,0763" "-95,32798" ...
## $ 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 : chr "0,24" "1700" "2" "0,36" ...
## $ LiberacionIntencionalBarriles : num 0 0 NA 0.05 0 NA 0 0 NA 25 ...
## $ RecuperacionLiquidoBarriles : chr "0,07" "1699" "0,48" "0" ...
## $ PerdidaNetaBarriles : chr "0,17" "1" "1,52" "0,36" ...
## $ IgnicionLiquido : chr "NO" "NO" "NO" "NO" ...
## $ ExplosionLiquido : chr "NO" "NO" "NO" "NO" ...
## $ CierreOleoducto : chr "YES" "YES" "NO" "NO" ...
## $ DiaCierre : int 8 25 NA NA 27 NA NA 23 15 11 ...
## $ MesCierre : int 4 3 NA NA 5 NA NA 5 3 1 ...
## $ AnioCierre : int 2010 2010 NA NA 2010 NA NA 2010 2010 2010 ...
## $ HoraCierre : int 6 18 NA NA 3 NA NA 7 16 2 ...
## $ AmPmCierre : chr "a. m." "p. m." NA NA ...
## $ DiaReinicio : int 9 28 NA NA 27 NA NA 23 15 15 ...
## $ MesReinicio : int 4 3 NA NA 5 NA NA 5 3 1 ...
## $ AnioReinicio : int 2010 2010 NA NA 2010 NA NA 2010 2010 2010 ...
## $ HoraReinicio : int 10 16 NA NA 24 NA NA 9 18 15 ...
## $ AmPmReinicio : chr "a. m." "p. m." NA NA ...
## $ EvacuacionesPublicas : int NA 0 NA NA 0 0 0 0 NA 0 ...
## $ LesionesEmpleadosOperador : int NA NA NA NA NA NA NA NA NA NA ...
## $ LesionesContratistasOperador : int NA NA NA NA NA NA NA NA NA NA ...
## $ LesionesRescatistasEmergencia : int NA NA NA NA NA NA NA NA NA NA ...
## $ OtrasLesiones : int NA NA NA NA NA NA NA NA NA NA ...
## $ LesionesPublico : int NA NA NA NA NA NA NA NA NA NA ...
## $ TodasLesiones : int NA NA NA NA NA NA NA NA NA NA ...
## $ FallecimientosEmpleadosOperador : int NA NA NA NA NA NA NA NA NA NA ...
## $ FallecimientosContratistasOperador : int NA NA NA NA NA NA NA NA NA NA ...
## $ FallecimientosRescatistasEmergencia : int NA NA NA NA NA NA NA NA NA NA ...
## $ OtrosFallecimientos : int NA NA NA NA NA NA NA NA NA NA ...
## $ FallecimientosPublico : int NA NA NA NA NA NA NA NA NA NA ...
## $ TodosFallecimientos : int NA NA NA NA NA NA NA NA NA NA ...
## $ CostosDaniosPropiedad : int 0 0 30000 12000 2720 NA 750 1300 NA 29360 ...
## $ CostosMercanciaPerdidas : int 27 0 100 30 1500 150 300 340 46 136233 ...
## $ CostosDaniosPropiedadesPublicasPrivadas: int 0 0 1000 5000 0 0 0 0 NA NA ...
## $ CostosRespuestaEmergencia : int 0 0 NA 0 1000 NA 400 2445 10999 NA ...
## $ CostosRemediacionAmbiental : int 0 100000 20000 15000 NA NA 6050 3350 452 NA ...
## $ OtrosCostos : int 0 0 NA 0 NA NA 0 2530 NA NA ...
## $ TodosCostos : int 27 100000 51100 32030 5220 150 7500 9965 11497 165593 ...
TDFFinalUbicacionOleoducto<- rbind(TablaUbicacionOleoducto, data.frame(
Ubicacion = "TOTAL",
ni = sum(TablaUbicacionOleoducto$ni),
hi_porc = 100
))
library(gt)
tabla_UbicacionOleoducto <- TDFFinalUbicacionOleoducto %>%
gt() %>%
cols_label(
Ubicacion = md("**Ubicación**"),
ni = md("**ni**"),
hi_porc = md("**hi(%)**")
) %>%
tab_header(
title = md("**Tabla N° 1**"),
subtitle = md("**Distribución de accidentes por Ubicación de Oleoductos 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"
) %>%
tab_style(
style = cell_text(weight = "bold"),
locations = cells_body(
rows = as.character(Ubicacion) == "TOTAL"
)
)
tabla_UbicacionOleoducto
Tabla N° 1 | ||
Distribución de accidentes por Ubicación de Oleoductos en EE.UU. (2010-2017) | ||
Ubicación | ni | hi(%) |
---|---|---|
OFFSHORE | 2 | 0.07 |
ONSHORE | 2758 | 99.93 |
TOTAL | 2760 | 100.00 |
Autor: Grupo 1 |
A continuación, las gráficas 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.
par(mar = c(6, 6, 4, 2))
barplot(
TablaUbicacionOleoducto$ni,
main = "Gráfica No.1: Distribución de la cantidad de accidentes
por Ubicación de Oleoductos en EE.UU.",
xlab = "Ubicación de Oleoductos",
ylab = "Cantidad",
col = "lightblue1",
names.arg = TablaUbicacionOleoducto$Ubicacion,
las = 1,
cex.main = 1.2,
cex.lab = 1.2,
cex.axis = 0.8,
cex.names = 0.8
)
par(mar = c(6, 6, 4, 2))
barplot(
TablaUbicacionOleoducto$ni,
main = "Gráfica No.2: Distribución de la cantidad de accidentes
por Ubicación de Oleoductos en relación al total en EE.UU.",
xlab = "Ubicación de Oleoductos",
ylab = "Cantidad",
names.arg = TablaUbicacionOleoducto$Ubicacion,
col = "lightblue2",
cex.main = 1.2,
las = 1,
cex.lab = 1.2,
cex.axis = 0.8,
cex.names = 0.8,
ylim = c(0,2760),
)
par(mar = c(6, 6, 4, 2))
barplot(
TablaUbicacionOleoducto$hi,
main = "Gráfica No.3: Distribución porcentual de accidentes
por Ubicación de Oleoductos en EE.UU.",
xlab = "Ubicación de Oleoductos",
ylab = "Porcentaje (%)",
names.arg = TablaUbicacionOleoducto$Ubicacion,
col = "lightblue3",
cex.main = 1.2,
las = 1,
cex.lab = 1.2,
cex.axis = 1,
cex.names = 0.8,
)
par(mar = c(6, 6, 4, 2))
barplot(
TablaUbicacionOleoducto$hi,
main = "Gráfica No.4: Distribución porcentual de accidentes
por Ubicación de Oleoductos en relación al total en EE.UU.",
xlab = "Ubicación de Oleoductos",
ylab = "Porcentaje (%)",
names.arg = TablaUbicacionOleoducto$Ubicacion,
col = "lightblue4",
cex.main = 1.2,
las = 1,
cex.lab = 1.2,
cex.axis = 1,
cex.names = 0.8,
ylim = c(0, 100)
)
par(mar = c(6, 6, 4, 2), xpd = TRUE)
colores_UbicacionOleoducto <- colorRampPalette(c("lightblue1", "royalblue3"))(nrow(TablaUbicacionOleoducto))
etiquetas_porcentaje <- paste0(TablaUbicacionOleoducto$hi, "%")
pie(
TablaUbicacionOleoducto$ni,
labels = etiquetas_porcentaje,
main = "Gráfica No.5:Distribución porcentual de accidentes por
Ubicación de Oleoductos en EE.UU.",
col = colores_UbicacionOleoducto,
cex.main = 1.2,
cex = 0.8
)
legend(
x = 1, y = -0.5,
legend = TablaUbicacionOleoducto$Ubicacion,
title = "Leyenda",
fill = colores_UbicacionOleoducto,
cex = 0.7,
y.intersp = 0.7,
bty = "o",
inset = 0.2
)
La ubicación de los oleoductos donde se concentra la mayor cantidad de accidentes en Estados Unidos es en: ONSHORE
La variable UbicacionOleoducto correspondiente a los
accidentes registrados en EE.UU. es de tipo nominal. Los resultados
evidencian que la categoría ONSHORE (tierra) concentra
prácticamente la totalidad de los accidentes, con un 99.93% del total,
mientras que OFFSHORE (mar adentro) representa apenas un 0.07%
durante el periodo analizado.