## 'data.frame': 3550 obs. of 23 variables:
## $ Id : int 6786 6250 8220 6241 6216 6620 6262 6229 6201 6221 ...
## $ Dia : int 19 3 21 16 19 7 10 12 18 29 ...
## $ Mes : int 1 6 4 3 12 10 2 5 3 1 ...
## $ Año : chr "A" "1979" "2010" "1978" ...
## $ Nombre : chr "Arabian Gulf Spills; Persian Gulf, Kuwait" "IXTOC I; Bahia de Campeche, Mexico" "Deepwater Horizon; Gulf of Mexico" "Amoco Cadiz; Brittany, France" ...
## $ Ubicacion : chr "Persian Gulf, Kuwait" "Bahia de Campeche, Mexico" "Gulf of Mexico" "Brittany, France" ...
## $ Latitud : chr "29,5" "19,4083" "28,7367" "48,5833" ...
## $ Longuitud : chr "48" "-92,325" "-88,3872" "-4,71667" ...
## $ Amenaza : chr "Oil" "Oil" "Oil" "Oil" ...
## $ Etiquetas : chr "" "Collision" "" "Grounding" ...
## $ Tipo_de_crudo : chr "Kuwait crude oil" "IXTOC I crude oil" "Diesel, crude oil" "Arabian light crude, Iranian light crude, Bunker C" ...
## $ Cantidad_recuperada_superficie : int NA NA 1 NA NA NA NA NA NA NA ...
## $ Cantidad_recuperada_costas : int NA NA 1 NA NA NA NA NA NA NA ...
## $ Cantidad_tratada_biologicamente : int 1 NA 1 1 NA NA NA NA NA NA ...
## $ Cantidad_dispersada_quimicamente: int NA 1 1 1 NA NA NA 1 1 1 ...
## $ Cantidad_quemada : int NA 1 1 NA NA NA NA 1 1 1 ...
## $ Maximo_liberacion_galones : int 336000009 -1 205000000 68000017 -1 -1 -1 9240000 36100000 -1 ...
## $ Barreras_de_contencion_flotantes: int 35 12 182 17 3 3 7 8 5 6 ...
## $ Causa_principal : chr "Daño del tanque " "Incendio y explosión " "Incendio y explosión " "Daño del tanque " ...
## $ Volumen_derramados_galones : chr "336.000.000" "365.000.000" "600.000.000" "68.000.000" ...
## $ Respuesta_actual_galones : chr "336000000" "252000000" "168000000" "68700000" ...
## $ Fuente_respuesta : chr "description and posts" "posts" "description" "posts" ...
## $ etiqueta_actualizacion : chr "RA updated" "RA newly acquired" "RA updated" "RA updated" ...
## Warning: NAs introduced by coercion
#Creación de los rangos
rango_Latitud <- cut(datos$Latitud,
breaks = seq(floor(min(datos$Latitud, na.rm = TRUE)), ceiling(max(datos$Latitud, na.rm = TRUE)), by = 10),
right = FALSE)
# Generación de la tabla de frecuencias
TDF_Latitud <- table(rango_Latitud)
tabla_Latitud <- as.data.frame(TDF_Latitud)
# Cálculo de los porcentajes
hi_Latitud <- (tabla_Latitud$Freq / sum(tabla_Latitud$Freq)) * 100
tabla_Latitud$hi <- round(hi_Latitud, 2)
# Cálculo de frecuencias acumuladas
Niasc_Latitud <- cumsum(tabla_Latitud$Freq)
Hiasc_Latitud <- cumsum(hi_Latitud)
Nidsc_Latitud <- rev(cumsum(rev(tabla_Latitud$Freq)))
Hidsc_Latitud <- rev(cumsum(rev(hi_Latitud)))
# Creación de la tabla final
tabla_Latitud_Final <- data.frame(
Rango_Latitud = levels(rango_Latitud),
Frecuencia = tabla_Latitud$Freq,
Porcentaje = tabla_Latitud$hi,
Niasc = Niasc_Latitud,
Hiasc = round(Hiasc_Latitud, 2),
Nidsc = Nidsc_Latitud,
Hidsc = round(Hidsc_Latitud, 2))
# Imprimir tabla final
print(tabla_Latitud_Final)
## Rango_Latitud Frecuencia Porcentaje Niasc Hiasc Nidsc Hidsc
## 1 [-78,-68) 1 3.85 1 3.85 26 100.00
## 2 [-68,-58) 0 0.00 1 3.85 25 96.15
## 3 [-58,-48) 1 3.85 2 7.69 25 96.15
## 4 [-48,-38) 0 0.00 2 7.69 24 92.31
## 5 [-38,-28) 1 3.85 3 11.54 24 92.31
## 6 [-28,-18) 0 0.00 3 11.54 23 88.46
## 7 [-18,-8) 0 0.00 3 11.54 23 88.46
## 8 [-8,2) 0 0.00 3 11.54 23 88.46
## 9 [2,12) 1 3.85 4 15.38 23 88.46
## 10 [12,22) 5 19.23 9 34.62 22 84.62
## 11 [22,32) 9 34.62 18 69.23 17 65.38
## 12 [32,42) 5 19.23 23 88.46 8 30.77
## 13 [42,52) 3 11.54 26 100.00 3 11.54
bp2 <- barplot(TDF_Latitud,
main = "Gráfica N°2: Frecuencia Total de la Latitud en Derrames Petroleros a Nivel Global",
cex.main = 0.8,
xlab = "Latitud",
ylab = "Cantidad",
names.arg = tabla_Latitud_Final$Rango_Latitud,
col = rainbow(length(TDF_Latitud)),
ylim = c(0, sum(TDF_Latitud) * 1.1)) # dejar espacio para los valores
# Añadir valores encima de las barras
text(x = bp2, y = TDF_Latitud, labels = TDF_Latitud, pos = 3, cex = 0.6, col = "black")
bp4 <- barplot(tabla_Latitud_Final$Porcentaje,
main = "Gráfica N°4: Porcentaje Global de la Latitud en Derrames Petroleros a Nivel Global",
cex.main = 0.8,
xlab = "Latitud",
ylab = "Porcentaje",
col = rainbow(length(TDF_Latitud)),
names.arg = tabla_Latitud_Final$Rango_Latitud,
ylim = c(0, 100 * 1.05)) # dejar un poco de espacio para el texto
# Añadir valores encima de las barras
text(x = bp4, y = tabla_Latitud_Final$Porcentaje, labels = paste0(tabla_Latitud_Final$Porcentaje, "%"),
pos = 3, cex = 0.6, col = "black")
x_Latitud <- 1:length(tabla_Latitud_Final$Rango_Latitud) # índice
y_ni_asc_Latitud <- tabla_Latitud_Final$Niasc
y_ni_dsc_Latitud <- tabla_Latitud_Final$Nidsc
plot(x_Latitud, y_ni_asc_Latitud,
type = "b",
main = "Gráfica N°6: Ojivas de la Latitud en Derrames Petroleros a Nivel Global",
cex.main = 0.8,
xlab = " Latitud",
ylab = "Frecuencia acumulada",
col = "black")
lines(x_Latitud, y_ni_dsc_Latitud, col = "blue", type = "b")
grid()
# Leyenda más a la izquierda
legend("topleft", legend = c("Ascendente", "Descendente"),
col = c("black", "blue"), lty = 1, cex = 0.8, inset = c(0.02, 0.29))
Los resultados muestran que la latitud con mayor frecuencia se encuentra en el rango [22,32) con un 34.62% , seguido por el rango [12,22) Y [32,42) con un 19.23% . La distribución es ligeramente asimétrica hacia el hemisferio norte y las ojivas confirman que más del 80% de los derrames ocurren en los primeros cuatro rangos. El diagrama de caja evidencia que la mayoría de los datos se concentran cerca de la mediana, con pocos valores extremos.