# Carga de Librerías
library(readxl)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(gt)
# Cargar base de datos
datos_nuevoartes <- read_excel("datos_deslizamientos.xlsx")
longitude <- datos_nuevoartes$longitude
longitude <- longitude[!is.na(longitude)]
# Número de observaciones
n_long <- length(longitude)
# Valores mínimo y máximo
min_long <- min(longitude)
max_long <- max(longitude)
# Rango
R_long <- max_long - min_long
# Número de clases según Sturges
k_sturges <- ceiling(1 + 3.322 * log10(n_long))
# Amplitud real
A_sturges <- R_long / k_sturges
# Límites inferiores
Li_sturges <- seq(
from = min_long,
by = A_sturges,
length.out = k_sturges
)
# Límites superiores
Ls_sturges <- c(
Li_sturges[-1],
max_long
)
# Marcas de clase
MC_sturges <- (Li_sturges + Ls_sturges) / 2
# Frecuencias absolutas
ni_sturges <- numeric(length(Li_sturges))
for(i in 1:length(Li_sturges)){
if(i < length(Li_sturges)){
ni_sturges[i] <- sum(
longitude >= Li_sturges[i] &
longitude < Ls_sturges[i]
)
}else{
ni_sturges[i] <- sum(
longitude >= Li_sturges[i] &
longitude <= Ls_sturges[i]
)
}
}
# Frecuencias relativas
hi_sturges <- round((ni_sturges/n_long)*100,2)
# Frecuencias acumuladas
Ni_asc_sturges <- cumsum(ni_sturges)
Ni_dsc_sturges <- rev(cumsum(rev(ni_sturges)))
Hi_asc_sturges <- round(cumsum(hi_sturges),2)
Hi_dsc_sturges <- round(rev(cumsum(rev(hi_sturges))),2)
# Intervalos
Intervalo_sturges <- paste0(
"[",
round(Li_sturges,2),
" - ",
round(Ls_sturges,2),
")"
)
Intervalo_sturges[length(Intervalo_sturges)] <- paste0(
"[",
round(Li_sturges[length(Li_sturges)],2),
" - ",
round(Ls_sturges[length(Ls_sturges)],2),
"]"
)
# Tabla
TDF_sturges <- data.frame(
Intervalo = Intervalo_sturges,
MC = round(MC_sturges,2),
ni = ni_sturges,
hi = hi_sturges,
Ni_asc = Ni_asc_sturges,
Ni_dsc = Ni_dsc_sturges,
Hi_asc = Hi_asc_sturges,
Hi_dsc = Hi_dsc_sturges
)
# Totales
TDF_sturges <- rbind(
TDF_sturges,
data.frame(
Intervalo = "TOTAL",
MC = "",
ni = sum(ni_sturges),
hi = 100,
Ni_asc = "",
Ni_dsc = "",
Hi_asc = "",
Hi_dsc = ""
)
)
tabla_sturges <- TDF_sturges %>%
gt() %>%
fmt_number(
columns = MC,
decimals = 2
) %>%
tab_header(
title = md("**Tabla N° 1**"),
subtitle = md(
paste0(
"Distribución de frecuencias de Longitude mediante la regla de Sturges (",
k_sturges,
" clases)"
)
)
) %>%
tab_source_note(
source_note = md("Autor: Grupo Geología")
) %>%
tab_style(
style = cell_text(weight = "bold"),
locations = cells_body(rows = Intervalo == "TOTAL")
)
tabla_sturges
| Tabla N° 1 | |||||||
| Distribución de frecuencias de Longitude mediante la regla de Sturges (15 clases) | |||||||
| Intervalo | MC | ni | hi | Ni_asc | Ni_dsc | Hi_asc | Hi_dsc |
|---|---|---|---|---|---|---|---|
| [-179.98 - -155.98) | -167.98 | 73 | 0.66 | 73 | 11033 | 0.66 | 100 |
| [-155.98 - -131.98) | -143.98 | 45 | 0.41 | 118 | 10960 | 1.07 | 99.34 |
| [-131.98 - -107.99) | -119.99 | 2633 | 23.86 | 2751 | 10915 | 24.93 | 98.93 |
| [-107.99 - -83.99) | -95.99 | 739 | 6.70 | 3490 | 8282 | 31.63 | 75.07 |
| [-83.99 - -59.99) | -71.99 | 1235 | 11.19 | 4725 | 7543 | 42.82 | 68.37 |
| [-59.99 - -35.99) | -47.99 | 222 | 2.01 | 4947 | 6308 | 44.83 | 57.18 |
| [-35.99 - -11.99) | -23.99 | 26 | 0.24 | 4973 | 6086 | 45.07 | 55.17 |
| [-11.99 - 12) | 0.01 | 459 | 4.16 | 5432 | 6060 | 49.23 | 54.93 |
| [12 - 36) | 24 | 280 | 2.54 | 5712 | 5601 | 51.77 | 50.77 |
| [36 - 60) | 48 | 172 | 1.56 | 5884 | 5321 | 53.33 | 48.23 |
| [60 - 84) | 72 | 1592 | 14.43 | 7476 | 5149 | 67.76 | 46.67 |
| [84 - 108) | 96 | 1731 | 15.69 | 9207 | 3557 | 83.45 | 32.24 |
| [108 - 132) | 120 | 1409 | 12.77 | 10616 | 1826 | 96.22 | 16.55 |
| [132 - 155.99) | 143.99 | 214 | 1.94 | 10830 | 417 | 98.16 | 3.78 |
| [155.99 - 179.99] | 167.99 | 203 | 1.84 | 11033 | 203 | 100 | 1.84 |
| TOTAL | 11033 | 100.00 | |||||
| Autor: Grupo Geología | |||||||
# ======================================================
# REDUCCIÓN DE INTERVALOS
# ======================================================
# Número de clases reducido
k_long <- 12
# Amplitud
A_real <- R_long / k_long
A_long <- ifelse(
A_real <= 2, 2,
ifelse(
A_real <= 5, 5,
ifelse(
A_real <= 10, 10,
ceiling(A_real/10)*10
)
)
)
# Límites inferiores
Li0 <- floor(min_long/A_long)*A_long
Li_long <- seq(
from = Li0,
by = A_long,
length.out = k_long
)
# Límites superiores
Ls_long <- Li_long + A_long
# Marcas de clase
MC_long <- round((Li_long + Ls_long)/2,2)
# Frecuencias absolutas
ni_long <- numeric(length(Li_long))
for(i in 1:length(Li_long)){
if(i < length(Li_long)){
ni_long[i] <- sum(
longitude >= Li_long[i] &
longitude < Ls_long[i]
)
}else{
ni_long[i] <- sum(
longitude >= Li_long[i] &
longitude <= Ls_long[i]
)
}
}
# Frecuencias relativas
hi_long <- round((ni_long/n_long)*100,2)
# Frecuencias acumuladas
Ni_asc_long <- cumsum(ni_long)
Ni_dsc_long <- rev(cumsum(rev(ni_long)))
Hi_asc_long <- round(cumsum(hi_long),2)
Hi_dsc_long <- round(rev(cumsum(rev(hi_long))),2)
# Tabla de frecuencias reducida
TDF_longitude <- data.frame(
Li = Li_long,
Ls = Ls_long,
MC = MC_long,
ni = ni_long,
hi = hi_long,
Ni_asc = Ni_asc_long,
Ni_dsc = Ni_dsc_long,
Hi_asc = Hi_asc_long,
Hi_dsc = Hi_dsc_long
)
# Totales
TDF_longitude <- rbind(
TDF_longitude,
data.frame(
Li = "TOTAL",
Ls = "",
MC = "",
ni = sum(ni_long),
hi = 100,
Ni_asc = "",
Ni_dsc = "",
Hi_asc = "",
Hi_dsc = ""
)
)
tabla_longitude <- TDF_longitude %>%
gt() %>%
fmt_number(
columns = MC,
decimals = 2
) %>%
tab_header(
title = md("**Tabla N° 2**"),
subtitle = md(
paste0(
"Distribución de frecuencias de Longitude (",
k_long,
" clases)"
)
)
) %>%
tab_source_note(
source_note = md("Autor: Grupo Geología")
) %>%
tab_style(
style = cell_text(weight = "bold"),
locations = cells_body(rows = Li == "TOTAL")
)
tabla_longitude
| Tabla N° 2 | ||||||||
| Distribución de frecuencias de Longitude (12 clases) | ||||||||
| Li | Ls | MC | ni | hi | Ni_asc | Ni_dsc | Hi_asc | Hi_dsc |
|---|---|---|---|---|---|---|---|---|
| -180 | -150 | -165 | 85 | 0.77 | 85 | 11033 | 0.77 | 100.02 |
| -150 | -120 | -135 | 1893 | 17.16 | 1978 | 10948 | 17.93 | 99.25 |
| -120 | -90 | -105 | 1221 | 11.07 | 3199 | 9055 | 29 | 82.09 |
| -90 | -60 | -75 | 1526 | 13.83 | 4725 | 7834 | 42.83 | 71.02 |
| -60 | -30 | -45 | 228 | 2.07 | 4953 | 6308 | 44.9 | 57.19 |
| -30 | 0 | -15 | 318 | 2.88 | 5271 | 6080 | 47.78 | 55.12 |
| 0 | 30 | 15 | 334 | 3.03 | 5605 | 5762 | 50.81 | 52.24 |
| 30 | 60 | 45 | 279 | 2.53 | 5884 | 5428 | 53.34 | 49.21 |
| 60 | 90 | 75 | 2034 | 18.44 | 7918 | 5149 | 71.78 | 46.68 |
| 90 | 120 | 105 | 1784 | 16.17 | 9702 | 3115 | 87.95 | 28.24 |
| 120 | 150 | 135 | 1083 | 9.82 | 10785 | 1331 | 97.77 | 12.07 |
| 150 | 180 | 165 | 248 | 2.25 | 11033 | 248 | 100.02 | 2.25 |
| TOTAL | 11033 | 100.00 | ||||||
| Autor: Grupo Geología | ||||||||
hist(
longitude,
breaks = c(Li_long, max(Ls_long)),
right = FALSE,
freq = TRUE,
col = "grey",
border = "black",
main = "Distribución local de la longitud de los deslizamientos\n a nivel mundial",
xlab = "Longitud (°)",
ylab = "Cantidad"
)
hist(
longitude,
breaks = c(Li_long, max(Ls_long)),
right = FALSE,
freq = TRUE,
col = "grey",
border = "black",
ylim = c(0, sum(ni_long)),
main = "Distribución global de la longitud de los deslizamientos\n a nivel mundial",
xlab = "Longitud (°)",
ylab = "Cantidad"
)
hist(
longitude,
breaks = c(Li_long, max(Ls_long)),
right = FALSE,
freq = FALSE,
col = "grey",
border = "black",
main = "Distribución local de la longitud de los deslizamientos\n a nivel mundial",
xlab = "Longitud (°)",
ylab = "Porcentaje"
)
hist(
longitude,
breaks = c(Li_long, max(Ls_long)),
right = FALSE,
freq = FALSE,
col = "grey",
border = "black",
ylim = c(0, max(hi_long) / 100 * 1.2),
main = "Distribución global de la longitud de los deslizamientos\n a nivel mundial",
xlab = "Longitud (°)",
ylab = "Porcentaje"
)
plot(
Ls_long,
Ni_asc_long,
type = "o",
pch = 19,
col = "blue",
ylim = c(0, max(Ni_asc_long)),
main = "Ojiva ascendente y descendente de la longitud\n de deslizamientos a nivel mundial",
xlab = "Longitud (°)",
ylab = "Cantidad"
)
lines(
Li_long,
Ni_dsc_long,
type = "o",
pch = 17,
col = "red"
)
legend(
"right",
legend = c("Ojiva ascendente (Ni ≤)", "Ojiva descendente (Ni ≥)"),
col = c("blue", "red"),
pch = c(19, 17),
lty = 1,
cex = 0.8,
bty = "b"
)
boxplot(
longitude,
horizontal = TRUE,
col = "grey",
border = "black",
main = "Diagrama de caja de la longitud de los deslizamientos\n a nivel mundial",
xlab = "Longitude (°)",
outline = TRUE,
pch = 19,
outcol = "red"
)
h <- hist(
longitude,
breaks = c(Li_long, max(Ls_long)),
right = FALSE,
plot = FALSE
)
plot(
h,
freq = TRUE,
col = "grey",
border = "black",
main = "Distribución y boxplot de la longitud de\n deslizamientos a nivel mundial",
xlab = "Longitude (°)",
ylab = "Cantidad"
)
boxplot(
longitude,
horizontal = TRUE,
add = TRUE,
axes = FALSE,
at = max(h$counts) * 0.45, # posición vertical
boxwex = max(h$counts) * 0.50, # altura de la caja
col = rgb(0.45, 0.80, 1.00, 0.70),
border = "black",
outline = TRUE,
pch = 19,
outcol = "red"
)
# Límites teóricos
ri <- -180
rs <- 180
# Media
media_long <- mean(longitude)
# Mediana
mediana_long <- median(longitude)
# Moda (redondeando a una cifra decimal)
moda_long <- as.numeric(
names(which.max(table(round(longitude, 1))))
)
# Rango
rango_long <- max(longitude) - min(longitude)
# Varianza
var_long <- var(longitude)
# Desviación estándar
sd_long <- sd(longitude)
# Coeficiente de variación (%)
CV_long <- (sd_long / abs(media_long)) * 100
# Coeficiente de asimetría de Fisher
As_long <- mean((longitude - media_long)^3) / sd_long^3
# Exceso de curtosis de Fisher
K_long <- mean((longitude - media_long)^4) / sd_long^4 - 3
TablaIndicadores_longitude <- data.frame(
Variable = "Longitud",
ri = ri,
rs = rs,
Media = round(media_long, 2),
Mediana = round(mediana_long, 2),
Moda = round(moda_long, 2),
Rango = round(rango_long, 2),
Varianza = round(var_long, 2),
Desv_Estandar = round(sd_long, 2),
CV = round(CV_long, 2),
Asimetria = round(As_long, 2),
Curtosis = round(K_long, 2)
)
tabla_longitude_indicadores <- TablaIndicadores_longitude %>%
gt() %>%
tab_header(
title = md("Tabla N° 2"),
subtitle = md("Resumen de indicadores estadísticos de la variable Longitud")
) %>%
tab_source_note(
source_note = md("Autor: Grupo 1 Geología")
)
tabla_longitude_indicadores
| Tabla N° 2 | |||||||||||
| Resumen de indicadores estadísticos de la variable Longitud | |||||||||||
| Variable | ri | rs | Media | Mediana | Moda | Rango | Varianza | Desv_Estandar | CV | Asimetria | Curtosis |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Longitud | -180 | 180 | 2.52 | 19.69 | -122.3 | 359.97 | 10182.5 | 100.91 | 4003.6 | -0.06 | -1.67 |
| Autor: Grupo 1 Geología | |||||||||||
Q1 <- quantile(longitude, 0.25)
Q3 <- quantile(longitude, 0.75)
IQR_long <- Q3 - Q1
lim_inf <- Q1 - 1.5 * IQR_long
lim_sup <- Q3 + 1.5 * IQR_long
outliers_vec <- longitude[
longitude < lim_inf |
longitude > lim_sup
]
tabla_outliers <- data.frame(
Variable = "Longitude",
Outliers_Detectados = length(outliers_vec),
Limite_Inferior = lim_inf,
Limite_Superior = lim_sup,
Q1 = Q1,
Q3 = Q3
)
tabla_outliers_gt <- tabla_outliers %>%
gt() %>%
tab_header(
title = md("**Tabla N° 3**"),
subtitle = md("Detección de valores atípicos de la longitud de ocurrencia de deslizamientos a nivel mundial")
) %>%
fmt_number(
columns = 3:6,
decimals = 2
) %>%
tab_source_note(
source_note = md("Elaborado por: Grupo 2 – Carrera de Geología")
)
tabla_outliers_gt
| Tabla N° 3 | |||||
| Detección de valores atípicos de la longitud de ocurrencia de deslizamientos a nivel mundial | |||||
| Variable | Outliers_Detectados | Limite_Inferior | Limite_Superior | Q1 | Q3 |
|---|---|---|---|---|---|
| Longitude | 0 | −410.60 | 396.68 | −107.87 | 93.95 |
| Elaborado por: Grupo 2 – Carrera de Geología | |||||
La variable longitud fluctúa entre -179.98 y 179.99, y sus valores giran entorno a 19.69 con una desviación estándar de 100.91, siendo un conjunto de datos muy heterogéneo. El conjunto de valores se concentra en la parte media de la variable. Sin la presencia de valores atípicos. Por lo tanto, esto se considera perjudicial a nivel mundial, debido a que los deslizamientos se distribuyen a lo largo de prácticamente todo el rango de longitudes.