library(readr)
library(dplyr)
library(ggplot2)
library(patchwork)
library(moments)
library(DT)
datos <- read.csv("C:/Users/kitsu/Downloads/glaciares_depurados.csv", na.strings = "-")
variable <- as.numeric(na.omit(datos[["Mean.Depth"]]))
n <- length(variable)
cat("Total de datos válidos analizados:", n)
## Total de datos válidos analizados: 70066
minimo <- min(variable)
maximo <- max(variable)
rango <- maximo - minimo
k_sturges <- ceiling(1 + 3.322 * log10(n))
amplitud_sturges <- rango / k_sturges
resumen_base <- data.frame(
Parametro = c("Mínimo", "Máximo", "Rango (R)", "Intervalos Sturges (k)", "Amplitud (A)"),
Valor = round(c(minimo, maximo, rango, k_sturges, amplitud_sturges), 2)
)
knitr::kable(resumen_base, caption = "Parámetros base de distribución")
| Parametro | Valor |
|---|---|
| Mínimo | 0.00 |
| Máximo | 7060.00 |
| Rango (R) | 7060.00 |
| Intervalos Sturges (k) | 18.00 |
| Amplitud (A) | 392.22 |
cortes_sturges <- seq(minimo, maximo, length.out = k_sturges + 1)
clases_sturges <- cut(variable, breaks = cortes_sturges, include.lowest = TRUE, right = FALSE)
ni <- as.vector(table(clases_sturges))
hi <- round((ni / n) * 100, 2)
Ni <- cumsum(ni)
Hi <- round((Ni / n) * 100, 2)
Xi <- round((cortes_sturges[-length(cortes_sturges)] + cortes_sturges[-1]) / 2, 2)
tabla_sturges <- data.frame(
Intervalo = levels(clases_sturges),
Xi = Xi,
ni = ni,
hi_porcentaje = hi,
Ni = Ni,
Hi_porcentaje = Hi
)
DT::datatable(tabla_sturges, caption = "Tabla de Distribución de Frecuencias (Regla de Sturges)")
cortes_reducidos <- pretty(variable, n = 6)
clases_reducidas <- cut(variable, breaks = cortes_reducidos, include.lowest = TRUE, right = FALSE)
ni_red <- as.vector(table(clases_reducidas))
hi_red <- round((ni_red / n) * 100, 2)
Ni_red <- cumsum(ni_red)
Hi_red <- round((Ni_red / n) * 100, 2)
Xi_red <- round((cortes_reducidos[-length(cortes_reducidos)] + cortes_reducidos[-1]) / 2, 2)
tabla_reducida <- data.frame(
Intervalo = levels(clases_reducidas),
Xi = Xi_red,
ni = ni_red,
hi_porcentaje = hi_red,
Ni = Ni_red,
Hi_porcentaje = Hi_red
)
knitr::kable(tabla_reducida, caption = "Tabla de Distribución de Frecuencias (Intervalos Reducidos)")
| Intervalo | Xi | ni | hi_porcentaje | Ni | Hi_porcentaje |
|---|---|---|---|---|---|
| [0,1e+03) | 500 | 70064 | 100 | 70064 | 100 |
| [1e+03,2e+03) | 1500 | 0 | 0 | 70064 | 100 |
| [2e+03,3e+03) | 2500 | 0 | 0 | 70064 | 100 |
| [3e+03,4e+03) | 3500 | 0 | 0 | 70064 | 100 |
| [4e+03,5e+03) | 4500 | 0 | 0 | 70064 | 100 |
| [5e+03,6e+03) | 5500 | 0 | 0 | 70064 | 100 |
| [6e+03,7e+03) | 6500 | 0 | 0 | 70064 | 100 |
| [7e+03,8e+03] | 7500 | 2 | 0 | 70066 | 100 |
Q1 <- quantile(variable, 0.25)
Q3 <- quantile(variable, 0.75)
IQR_val <- Q3 - Q1
lim_inf <- Q1 - 1.5 * IQR_val
lim_sup <- Q3 + 1.5 * IQR_val
datos_comunes <- variable[variable >= lim_inf & variable <= lim_sup]
datos_atipicos <- variable[variable < lim_inf | variable > lim_sup]
tema_uniforme <- theme_minimal() +
theme(
plot.title = element_text(size = 11.5, face = "bold", color = "#1F2E3D", hjust = 0.5),
axis.title = element_text(size = 10, color = "#1F2E3D")
)
# Preparación Datos Comunes
cortes_com <- pretty(datos_comunes, n = 7)
amp_com <- cortes_com[2] - cortes_com[1]
h_com <- hist(datos_comunes, breaks = cortes_com, plot = FALSE)
df_poli_com <- data.frame(
x = c(min(cortes_com) - amp_com/2, h_com[["mids"]], max(cortes_com) + amp_com/2),
y = c(0, h_com[["counts"]], 0)
)
# Preparación Datos No Comunes
cortes_ati <- pretty(datos_atipicos, n = 7)
amp_ati <- cortes_ati[2] - cortes_ati[1]
h_ati <- hist(datos_atipicos, breaks = cortes_ati, plot = FALSE)
df_poli_ati <- data.frame(
x = c(min(cortes_ati) - amp_ati/2, h_ati[["mids"]], max(cortes_ati) + amp_ati/2),
y = c(0, h_ati[["counts"]], 0)
)
# --- GRÁFICA NRO. 1: CANTIDAD (ESCALA LOCAL) - DATOS COMUNES ---
ggplot(data.frame(valor = datos_comunes), aes(x = valor)) +
geom_histogram(breaks = cortes_com, fill = "#4A6B82", color = "white", alpha = 0.85) +
stat_bin(breaks = cortes_com, geom = "text", aes(label = after_stat(count)), vjust = -0.4, size = 3.2, color = "#1F2E3D") +
geom_line(data = df_poli_com, aes(x = x, y = y), color = "#1F2E3D", linewidth = 0.9) +
geom_point(data = df_poli_com, aes(x = x, y = y), color = "#1F2E3D", size = 2) +
scale_x_continuous(breaks = cortes_com) +
labs(title = "Gráfica Nro.1 de distribución de la profundidad media\nen el estudio de glaciares (Datos Comunes - Escala Local)",
x = "Profundidad media (m)",
y = "Cantidad") +
tema_uniforme
Justificación (Común): Debido a que en la gráfica general la mayoría de los registros se concentra en los primeros intervalos por efecto de los valores extremos, se separan los 66735 glaciares dentro de los límites normales (\(\leq 72\) m) para visualizar con claridad la distribución real de la mayoría de los datos.
# --- GRÁFICA NRO. 2: CANTIDAD (ESCALA LOCAL) - DATOS NO COMUNES ---
ggplot(data.frame(valor = datos_atipicos), aes(x = valor)) +
geom_histogram(breaks = cortes_ati, fill = "#7A93A6", color = "white", alpha = 0.85) +
stat_bin(breaks = cortes_ati, geom = "text", aes(label = after_stat(count)), vjust = -0.4, size = 3.2, color = "#1F2E3D") +
geom_line(data = df_poli_ati, aes(x = x, y = y), color = "#1F2E3D", linewidth = 0.9) +
geom_point(data = df_poli_ati, aes(x = x, y = y), color = "#1F2E3D", size = 2) +
scale_x_continuous(breaks = cortes_ati) +
labs(title = "Gráfica Nro.2 de distribución de la profundidad media\nen el estudio de glaciares (Datos No Comunes - Escala Local)",
x = "Profundidad media (m)",
y = "Cantidad") +
tema_uniforme
Justificación (No Común): Esta gráfica agrupa únicamente los 3331 glaciares atípicos con profundidades medias excepcionalmente grandes (superiores a 72 m), permitiendo analizar su dispersión extrema sin distorsionar la escala del grupo principal.
# --- GRÁFICA NRO. 3: CANTIDAD (ESCALA TOTAL N) - DATOS COMUNES ---
ggplot(data.frame(valor = datos_comunes), aes(x = valor)) +
geom_histogram(breaks = cortes_com, fill = "#3D5A73", color = "white", alpha = 0.85) +
stat_bin(breaks = cortes_com, geom = "text", aes(label = after_stat(count)), vjust = -0.4, size = 3.2, color = "#1F2E3D") +
geom_line(data = df_poli_com, aes(x = x, y = y), color = "#1F2E3D", linewidth = 0.9) +
geom_point(data = df_poli_com, aes(x = x, y = y), color = "#1F2E3D", size = 2) +
scale_x_continuous(breaks = cortes_com) +
ylim(0, length(datos_comunes)) +
labs(title = "Gráfica Nro.3 de distribución de la profundidad media\nen el estudio de glaciares (Datos Comunes - Escala Total)",
x = "Profundidad media (m)",
y = "Cantidad") +
tema_uniforme
# --- GRÁFICA NRO. 4: CANTIDAD (ESCALA TOTAL N) - DATOS NO COMUNES ---
ggplot(data.frame(valor = datos_atipicos), aes(x = valor)) +
geom_histogram(breaks = cortes_ati, fill = "#5C768D", color = "white", alpha = 0.85) +
stat_bin(breaks = cortes_ati, geom = "text", aes(label = after_stat(count)), vjust = -0.4, size = 3.2, color = "#1F2E3D") +
geom_line(data = df_poli_ati, aes(x = x, y = y), color = "#1F2E3D", linewidth = 0.9) +
geom_point(data = df_poli_ati, aes(x = x, y = y), color = "#1F2E3D", size = 2) +
scale_x_continuous(breaks = cortes_ati) +
ylim(0, length(datos_atipicos)) +
labs(title = "Gráfica Nro.4 de distribución de la profundidad media\nen el estudio de glaciares (Datos No Comunes - Escala Total)",
x = "Profundidad media (m)",
y = "Cantidad") +
tema_uniforme
# --- GRÁFICA NRO. 5: PORCENTUAL (ESCALA LOCAL) - DATOS COMUNES ---
df_poli_com[["y_pct"]] <- (df_poli_com[["y"]] / length(datos_comunes)) * 100
ggplot(data.frame(valor = datos_comunes), aes(x = valor)) +
geom_histogram(aes(y = after_stat(count / sum(count)) * 100),
breaks = cortes_com, fill = "#6C8E9E", color = "white", alpha = 0.85) +
stat_bin(breaks = cortes_com, geom = "text",
aes(y = after_stat(count / sum(count)) * 100, label = paste0(round(after_stat(count / sum(count)) * 100, 1), "%")),
vjust = -0.4, size = 3.2, color = "#1F2E3D") +
geom_line(data = df_poli_com, aes(x = x, y = y_pct), color = "#1F2E3D", linewidth = 0.9) +
geom_point(data = df_poli_com, aes(x = x, y = y_pct), color = "#1F2E3D", size = 2) +
scale_x_continuous(breaks = cortes_com) +
labs(title = "Gráfica Nro.5 de distribución porcentual de la profundidad media\nen el estudio de glaciares (Datos Comunes - Escala Local)",
x = "Profundidad media (m)",
y = "Porcentaje (%)") +
tema_uniforme
# --- GRÁFICA NRO. 6: PORCENTUAL (ESCALA LOCAL) - DATOS NO COMUNES ---
df_poli_ati[["y_pct"]] <- (df_poli_ati[["y"]] / length(datos_atipicos)) * 100
ggplot(data.frame(valor = datos_atipicos), aes(x = valor)) +
geom_histogram(aes(y = after_stat(count / sum(count)) * 100),
breaks = cortes_ati, fill = "#8FA3B0", color = "white", alpha = 0.85) +
stat_bin(breaks = cortes_ati, geom = "text",
aes(y = after_stat(count / sum(count)) * 100, label = paste0(round(after_stat(count / sum(count)) * 100, 1), "%")),
vjust = -0.4, size = 3.2, color = "#1F2E3D") +
geom_line(data = df_poli_ati, aes(x = x, y = y_pct), color = "#1F2E3D", linewidth = 0.9) +
geom_point(data = df_poli_ati, aes(x = x, y = y_pct), color = "#1F2E3D", size = 2) +
scale_x_continuous(breaks = cortes_ati) +
labs(title = "Gráfica Nro.6 de distribución porcentual de la profundidad media\nen el estudio de glaciares (Datos No Comunes - Escala Local)",
x = "Profundidad media (m)",
y = "Porcentaje (%)") +
tema_uniforme
# --- GRÁFICA NRO. 7: PORCENTUAL (ESCALA 0 A 100%) - DATOS COMUNES ---
ggplot(data.frame(valor = datos_comunes), aes(x = valor)) +
geom_histogram(aes(y = after_stat(count / sum(count)) * 100),
breaks = cortes_com, fill = "#4A6B82", color = "white", alpha = 0.85) +
stat_bin(breaks = cortes_com, geom = "text",
aes(y = after_stat(count / sum(count)) * 100, label = paste0(round(after_stat(count / sum(count)) * 100, 1), "%")),
vjust = -0.4, size = 3.2, color = "#1F2E3D") +
geom_line(data = df_poli_com, aes(x = x, y = y_pct), color = "#1F2E3D", linewidth = 0.9) +
geom_point(data = df_poli_com, aes(x = x, y = y_pct), color = "#1F2E3D", size = 2) +
scale_x_continuous(breaks = cortes_com) +
ylim(0, 100) +
labs(title = "Gráfica Nro.7 de distribución porcentual de la profundidad media\nen el estudio de glaciares (Datos Comunes - Escala Total)",
x = "Profundidad media (m)",
y = "Porcentaje (%)") +
tema_uniforme
# --- GRÁFICA NRO. 8: PORCENTUAL (ESCALA 0 A 100%) - DATOS NO COMUNES ---
ggplot(data.frame(valor = datos_atipicos), aes(x = valor)) +
geom_histogram(aes(y = after_stat(count / sum(count)) * 100),
breaks = cortes_ati, fill = "#7A93A6", color = "white", alpha = 0.85) +
stat_bin(breaks = cortes_ati, geom = "text",
aes(y = after_stat(count / sum(count)) * 100, label = paste0(round(after_stat(count / sum(count)) * 100, 1), "%")),
vjust = -0.4, size = 3.2, color = "#1F2E3D") +
geom_line(data = df_poli_ati, aes(x = x, y = y_pct), color = "#1F2E3D", linewidth = 0.9) +
geom_point(data = df_poli_ati, aes(x = x, y = y_pct), color = "#1F2E3D", size = 2) +
scale_x_continuous(breaks = cortes_ati) +
ylim(0, 100) +
labs(title = "Gráfica Nro.8 de distribución porcentual de la profundidad media\nen el estudio de glaciares (Datos No Comunes - Escala Total)",
x = "Profundidad media (m)",
y = "Porcentaje (%)") +
tema_uniforme
# --- GRÁFICA NRO. 9: CAJA SOBREPUESTA AL HISTOGRAMA GENERAL ---
h_gen <- hist(variable, breaks = cortes_sturges, plot = FALSE)
altura_max <- max(h_gen[["counts"]])
ggplot(data.frame(valor = variable), aes(x = valor)) +
geom_histogram(breaks = cortes_sturges, fill = "#5C768D", color = "white", alpha = 0.8) +
geom_boxplot(aes(y = altura_max * 0.85), width = altura_max * 0.14,
fill = "#8FA3B0", color = "#1F2E3D", alpha = 0.9,
outlier.color = "#3B4A54", outlier.size = 1.4) +
labs(title = "Gráfica Nro.9 de distribución y dispersión de la profundidad\nmedia en el estudio de glaciares",
x = "Profundidad media (m)",
y = "Cantidad") +
tema_uniforme
# --- GRÁFICA NRO. 10: OJIVA ASCENDENTE Y DESCENDENTE ---
df_ojiva <- data.frame(
limite = cortes_sturges,
Ascendente = c(0, Hi),
Descendente = c(100, 100 - Hi)
)
ggplot(df_ojiva, aes(x = limite)) +
geom_line(aes(y = Ascendente, color = "Ascendente (<)"), linewidth = 1.2) +
geom_point(aes(y = Ascendente, color = "Ascendente (<)"), size = 2.5) +
geom_line(aes(y = Descendente, color = "Descendente (>)"), linewidth = 1.2, linetype = "dashed") +
geom_point(aes(y = Descendente, color = "Descendente (>)"), size = 2.5) +
scale_color_manual(name = "Distribución acumulada", values = c("Ascendente (<)" = "#3D5A73", "Descendente (>)" = "#8FA3B0")) +
labs(title = "Gráfica Nro.10 de distribución acumulada de la profundidad\nmedia en el estudio de glaciares",
x = "Profundidad media (m)",
y = "Porcentaje acumulado (%)") +
tema_uniforme +
theme(legend.position = "bottom")
get_moda <- function(v) {
uniqv <- unique(v)
uniqv[which.max(tabulate(match(v, uniqv)))]
}
indicadores <- data.frame(
Indicador = c("Mínimo", "Cuartil 1 (Q1)", "Mediana (Me)", "Media", "Moda (Mo)",
"Cuartil 3 (Q3)", "Máximo", "Rango", "Rango Intercuartílico (IQR)",
"Desviación Estándar (DE)", "Varianza", "Coeficiente de Variación (%)",
"Asimetría (AS)", "Curtosis (K)", "Cantidad de Outliers"),
Valor = round(c(
min(variable), Q1, median(variable), mean(variable), get_moda(variable),
Q3, max(variable), rango, IQR_val,
sd(variable), var(variable), (sd(variable) / mean(variable)) * 100,
skewness(variable), kurtosis(variable), length(datos_atipicos)
), 2)
)
knitr::kable(indicadores, caption = "Resumen de Indicadores Estadísticos y Conteo de Outliers")
| Indicador | Valor |
|---|---|
| Mínimo | 0.00 |
| Cuartil 1 (Q1) | 12.00 |
| Mediana (Me) | 20.00 |
| Media | 28.42 |
| Moda (Mo) | 10.00 |
| Cuartil 3 (Q3) | 36.00 |
| Máximo | 7060.00 |
| Rango | 7060.00 |
| Rango Intercuartílico (IQR) | 24.00 |
| Desviación Estándar (DE) | 46.48 |
| Varianza | 2160.56 |
| Coeficiente de Variación (%) | 163.58 |
| Asimetría (AS) | 99.57 |
| Curtosis (K) | 14908.97 |
| Cantidad de Outliers | 3331.00 |
cat("Valores atípicos (Outliers) encontrados (> ", round(lim_sup, 2), " m):\n")
## Valores atípicos (Outliers) encontrados (> 72 m):
sort(unique(datos_atipicos))
## [1] 72.01 72.05 72.06 72.12 72.40 72.51 72.56 72.57 72.67
## [10] 72.73 72.78 72.84 72.89 73.00 73.01 73.06 73.22 73.27
## [19] 73.28 73.49 73.60 73.65 73.71 73.76 73.81 73.87 73.92
## [28] 73.97 74.00 74.02 74.13 74.18 74.29 74.34 74.39 74.45
## [37] 74.55 74.82 74.86 74.97 75.00 75.02 75.07 75.28 75.33
## [46] 75.36 75.38 75.47 75.48 75.58 75.73 75.84 75.89 75.99
## [55] 76.00 76.14 76.24 76.34 76.39 76.54 76.77 76.78 76.83
## [64] 76.93 77.00 77.02 77.03 77.06 77.07 77.17 77.32 77.37
## [73] 77.53 77.80 77.85 77.90 77.95 78.00 78.04 78.28 78.42
## [82] 78.47 78.72 78.79 78.93 79.00 79.03 79.31 79.32 79.46
## [91] 79.53 79.54 79.76 79.85 79.90 79.99 80.00 80.13 80.17
## [100] 80.22 80.26 80.31 80.35 80.40 80.53 80.89 81.00 81.02
## [109] 81.20 81.24 81.28 81.33 81.46 81.50 81.54 81.72 81.76
## [118] 81.80 81.89 81.93 82.00 82.02 82.11 82.19 82.70 82.87
## [127] 83.00 83.21 83.46 83.50 83.58 83.66 83.68 83.87 83.91
## [136] 84.00 84.20 84.28 84.32 84.60 84.64 84.96 85.00 85.04
## [145] 85.08 85.24 85.33 85.36 85.40 85.67 85.68 85.72 85.73
## [154] 86.00 86.15 86.26 86.49 86.92 86.99 87.00 87.07 87.41
## [163] 87.60 87.63 87.71 87.75 87.79 88.00 88.16 88.30 88.31
## [172] 89.00 89.18 89.22 89.29 89.58 89.65 89.72 90.00 90.01
## [181] 90.04 90.12 90.15 90.43 90.51 90.54 90.68 90.99 91.00
## [190] 91.41 91.44 91.61 91.72 91.85 92.00 92.06 93.00 93.33
## [199] 93.65 93.75 93.85 93.91 94.00 94.48 94.75 94.85 94.99
## [208] 95.00 95.42 95.45 95.51 96.00 96.17 96.32 96.35 96.54
## [217] 96.63 96.81 96.82 96.87 96.90 97.00 97.06 97.24 97.90
## [226] 98.00 98.02 98.16 98.28 98.37 98.43 98.50 98.52 98.60
## [235] 98.78 98.81 98.84 98.96 99.00 99.16 99.22 100.00 100.17
## [244] 100.33 100.34 100.39 100.65 100.74 100.87 100.97 101.00 101.01
## [253] 101.21 101.28 101.87 101.95 102.00 102.06 102.93 103.00 103.12
## [262] 103.22 103.36 103.81 104.00 104.12 105.00 105.11 105.24 105.82
## [271] 105.85 105.90 106.00 106.15 106.58 106.65 106.90 107.00 107.02
## [280] 107.51 107.93 108.00 108.40 108.57 108.65 109.00 109.13 109.15
## [289] 110.00 110.19 110.20 110.23 111.00 111.63 111.97 112.00 112.10
## [298] 112.44 112.45 112.87 113.00 113.37 113.92 114.00 114.51 114.73
## [307] 115.00 115.05 115.19 115.28 115.68 115.91 116.00 116.92 117.00
## [316] 117.29 118.00 118.26 118.66 119.00 119.19 119.93 120.00 120.01
## [325] 120.19 120.36 121.00 121.09 122.00 122.27 123.00 123.14 123.29
## [334] 123.50 124.00 124.23 124.43 124.83 125.00 125.04 125.16 125.82
## [343] 126.00 126.18 126.41 127.00 127.03 127.20 128.00 128.86 129.00
## [352] 129.09 129.52 129.68 130.00 131.00 131.18 131.24 132.00 132.57
## [361] 132.86 133.00 134.00 134.04 135.00 135.89 136.00 136.18 137.00
## [370] 138.00 139.00 139.07 139.25 139.39 140.00 141.00 141.28 141.56
## [379] 142.00 143.00 143.19 144.00 144.11 144.55 145.00 145.09 145.87
## [388] 146.00 146.05 147.00 147.34 147.82 148.00 148.76 149.00 149.38
## [397] 149.97 150.00 150.48 151.00 152.00 153.00 154.00 155.00 155.82
## [406] 156.00 156.55 156.76 157.00 158.00 159.00 159.98 160.00 162.00
## [415] 163.00 163.19 163.55 163.58 164.00 164.05 165.00 166.00 167.00
## [424] 167.45 167.78 168.11 169.00 170.00 171.00 172.00 173.00 174.00
## [433] 175.00 175.49 176.00 177.00 177.31 178.00 179.00 180.00 181.00
## [442] 182.00 182.06 183.00 184.00 185.00 187.00 187.47 188.00 188.71
## [451] 189.00 190.00 191.00 192.00 193.00 194.00 194.26 195.00 196.00
## [460] 198.00 199.00 200.00 201.84 203.00 204.00 205.00 205.60 206.00
## [469] 209.00 210.00 211.00 212.00 213.00 215.00 216.00 217.00 219.00
## [478] 220.00 222.00 223.00 225.55 230.00 232.00 234.00 235.00 238.00
## [487] 239.00 240.00 241.00 242.82 243.00 246.00 248.00 249.00 250.00
## [496] 252.00 258.00 260.00 265.00 268.00 269.81 270.00 278.69 279.93
## [505] 280.00 283.43 287.00 290.00 294.00 300.00 305.00 315.90 320.00
## [514] 350.00 358.59 380.00 400.00 418.36 450.00 500.00 600.00 7049.00
## [523] 7060.00
La Profundidad media (Mean Depth)
fluctúa entre 0.00 m y 7,060.00 m y su valor
representativo gira en torno a 20.00 m (se toma la
Mediana debido a la presencia de valores extremos),
siendo un conjunto de valores muy heterogéneos (\(CV = 163.58\%\)), donde la concentración de
datos es fuerte en la parte baja de la variable (\(99.97\%\) en el primer intervalo) y con la
incidencia de 3,331 valores atípicos (que van desde
72.01 m hasta 7,060.00 m). Bajo nuestro criterio, este
comportamiento es beneficioso desde el punto de vista
hídrico, ya que indica la existencia de masas glaciares con un espesor
considerable que almacenan importantes reservas de agua dulce.