ANÁLISIS ESTADÍSTICO

1. CARGA DE DATOS Y LIBRERÍAS

CARGA DE DATOS

# Ruta completa al archivo
datos <- read.csv("C:/Users/Grace/Downloads/Sedimentos Marinos (1).csv",
                  header = TRUE,
                  sep = ";",
                  dec = ".")
# Limpiamos la Variable
lat_str <- gsub("[^0-9]", "", datos$LATITUDE)
latitud <- sapply(lat_str, function(s) {
  if (s == "" || nchar(s) < 3) NA else as.numeric(s) / 10^(nchar(s) - 2)
})
latitud <- latitud[latitud >= -90 & latitud <= 90]
latitud <- na.omit(latitud)
# Calculamos el número de datos
n <- length(latitud)

Librerias

**CARGA DE LIBRERÍAS**
library(gt)
library(dplyr)
library(knitr)
library(kableExtra)
library(moments)

TABLA DE DISTRIBUCIÓN

**TABLA DE DISTRIBUCIÓN DE FRECUENCIA**
k <- 10
# Min, Max
minimo <- min(latitud)
maximo <- max(latitud)
# Rango
R <- maximo - minimo
# Amplitud
A <- R / k
# Límites inferior (Li) y superior (Ls)
Li <- round(seq(from = minimo, to = maximo - A, by = A), 2)
Ls <- round(seq(from = minimo + A, to = maximo, by = A), 2)
# Marca de clase
MC <- round((Li + Ls) / 2, 2)
# Frecuencia Absoluta (ni)
ni <- numeric(length(Li))
for (i in 1:length(Li)) {
  if (i == length(Li)) {
    ni[i] <- sum(latitud >= Li[i])
  } else {
    ni[i] <- sum(latitud >= Li[i] & latitud < Ls[i])
  }
}
# Frecuencia Relativa (hi)
hi <- round((ni / sum(ni)) * 100, 2)
# Frecuencias Acumuladas
Niasc <- cumsum(ni)
Nidsc <- rev(cumsum(rev(ni)))
Hiasc <- round(cumsum(hi), 2)
Hidsc <- round(rev(cumsum(rev(hi))), 2)
# TABLA FINAL
TDFlatitud <- data.frame(
  Li, Ls, MC, ni, hi, Niasc, Nidsc, Hiasc, Hidsc
)
TDFlatitud
##       Li    Ls    MC   ni    hi Niasc Nidsc  Hiasc  Hidsc
## 1  15.31 21.86 18.59  394  2.80   394 14081   2.80 100.00
## 2  21.86 28.41 25.13  751  5.33  1145 13687   8.13  97.20
## 3  28.41 34.96 31.69  932  6.62  2077 12936  14.75  91.87
## 4  34.96 41.51 38.24 6254 44.41  8331 12004  59.16  85.25
## 5  41.51 48.06 44.78 5307 37.69 13638  5750  96.85  40.84
## 6  48.06 54.61 51.34   12  0.09 13650   443  96.94   3.15
## 7  54.61 61.16 57.88   56  0.40 13706   431  97.34   3.06
## 8  61.16 67.71 64.44  151  1.07 13857   375  98.41   2.66
## 9  67.71 74.26 70.98  220  1.56 14077   224  99.97   1.59
## 10 74.26 80.81 77.53    4  0.03 14081     4 100.00   0.03
**TABLA DE DISTRIBUCIÓN DE LONGITUD POR STURGES FINAL**
# Fila total
fila_total <- data.frame(
  Li = "TOTAL",
  Ls = "",
  MC = "",
  ni = sum(TDFlatitud$ni),
  hi = round(sum(TDFlatitud$hi), 2),
  Niasc = "",
  Nidsc = "",
  Hiasc = "",
  Hidsc = ""
)
TDFlatitud_p <- rbind(TDFlatitud, fila_total)
tabla_latitud_p <- TDFlatitud_p %>%
  gt() %>%
  tab_header(
    title = md("*Tabla Nº:1*"),
    subtitle = md("Tabla de distribución de la latitud de los sedimentos marinos (10 clases)")
  ) %>%
  tab_source_note(
    source_note = md("Autor: Grupo 3")
  ) %>%
  tab_options(
    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),
    row.striping.include_table_body = TRUE,
    heading.border.bottom.color = "black",
    heading.border.bottom.width = px(2),
    table_body.hlines.color = "gray",
    table_body.border.bottom.color = "black"
  )
tabla_latitud_p
Tabla Nº:1
Tabla de distribución de la latitud de los sedimentos marinos (10 clases)
Li Ls MC ni hi Niasc Nidsc Hiasc Hidsc
15.31 21.86 18.59 394 2.80 394 14081 2.8 100
21.86 28.41 25.13 751 5.33 1145 13687 8.13 97.2
28.41 34.96 31.69 932 6.62 2077 12936 14.75 91.87
34.96 41.51 38.24 6254 44.41 8331 12004 59.16 85.25
41.51 48.06 44.78 5307 37.69 13638 5750 96.85 40.84
48.06 54.61 51.34 12 0.09 13650 443 96.94 3.15
54.61 61.16 57.88 56 0.40 13706 431 97.34 3.06
61.16 67.71 64.44 151 1.07 13857 375 98.41 2.66
67.71 74.26 70.98 220 1.56 14077 224 99.97 1.59
74.26 80.81 77.53 4 0.03 14081 4 100 0.03
TOTAL 14081 100.00
Autor: Grupo 3

Colores

**Colores de las barras**
colores <- gray.colors(length(ni), start = 0.3, end = 0.9)

GRÁFICAS

**Histograma de cantidad Local**
hist(
  latitud,
  breaks = 10,  # Forzamos 10 barras
  main = "Gráfica Nº2: Distribución de la latitud de los sedimentos marinos",
  xlab = "Latitud (grados)",
  ylab = "Cantidad",
  col = colores
)

**Histograma de cantidad global**
hist(
  latitud,
  breaks = 10,
  main = "Gráfica Nº3: Distribución de la latitud de los sedimentos marinos",
  xlab = "Latitud (grados)",
  ylab = "Cantidad",
  col = colores,
  ylim = c(0, max(ni) + 50)
)

**Histograma de cantidad en porcentaje**
barplot(
  hi,
  names.arg = MC,
  col = colores,
  ylim = c(0, max(hi) + 5),
  space = 0,
  cex.names = 0.8,
  ylab = "Porcentaje (%)",
  xlab = "Latitud (grados)",
  main = "Gráfica Nº4: Distribución de porcentaje de la latitud de los sedimentos marinos",
  las = 2
)

**Histograma de cantidad en porcentaje global**
barplot(
  hi,
  names.arg = MC,
  col = colores,
  ylim = c(0, 100),
  cex.names = 0.8,
  space = 0,
  ylab = "Porcentaje (%)",
  xlab = "Latitud (grados)",
  main = "Gráfica Nº5: Distribución de porcentaje de la latitud de los sedimentos marinos",
  las = 2
)

**DIAGRAMA DE CAJA**
boxplot(
  latitud,
  horizontal = TRUE,
  main = "Gráfica Nº6: Distribución de la latitud de los sedimentos marinos",
  xlab = "Latitud (grados)",
  col = "lightblue"
)

**Ojivas combinadas Ni**
lim_sup <- Ls
plot(lim_sup, Nidsc, type="o",
     main="Gráfica Nº7: Ojiva combinada de la latitud (Ni)",
     ylab="Cantidad Acumulada", col="blue", xlab="Latitud (grados)")
lines(Li, Niasc, col="red", type="o")
legend("topleft", legend = c("Descendente", "Ascendente"), col = c("blue", "red"), lty = 1, pch = 1)

**Ojivas combinadas Hi**
plot(lim_sup, Hidsc, type="o",
     main="Gráfica Nº8: Ojiva combinada de la latitud (Hi)",
     ylab="Porcentaje Acumulado (%)", col="blue", xlab="Latitud (grados)")
lines(Li, Hiasc, col="red", type="o")
legend("bottomright", legend = c("Descendente", "Ascendente"), col = c("blue", "red"), lty = 1, pch = 1)

INDICADORES Y OUTLERS

**Indicadores Estadísticos**
summary(latitud)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   15.31   40.03   41.25   39.97   42.35   80.81
# POSICIÓN
x <- mean(latitud)
Me <- median(latitud)
# DISPERSIÓN
sd_val <- sd(latitud)
CV <- round((sd_val / abs(x)) * 100, 2)
# FORMA
As <- skewness(latitud)
K <- kurtosis(latitud)
# TABLA DE INDICADORES ESTADÍSTICOS
Variable <- c("Latitud (grados)")
TablaIndicadores <- data.frame(Variable, round(minimo,2), round(maximo,2), round(x,2), round(Me,2), round(sd_val,2), CV, round(As,2), round(K,2))
colnames(TablaIndicadores) <- c("Variable","Mínimo","Máximo","Media","Mediana","Desv. Est.","CV (%)","Asimetría","Curtosis")
kable(TablaIndicadores, format = "markdown", caption = "Tabla N°3: Indicadores estadísticos de la variable latitud en sedimentos marinos")
Tabla N°3: Indicadores estadísticos de la variable latitud en sedimentos marinos
Variable Mínimo Máximo Media Mediana Desv. Est. CV (%) Asimetría Curtosis
Latitud (grados) 15.31 80.81 39.97 41.25 7.39 18.49 0.44 8.71

Outliers

**TABLA DE OUTLIERS**
outliers <- boxplot.stats(latitud)$out
num_outliers <- length(outliers)
min_outlier <- if(num_outliers > 0) min(outliers) else NA
max_outlier <- if(num_outliers > 0) max(outliers) else NA
TablaOutliers <- data.frame(num_outliers, round(min_outlier,2), round(max_outlier,2))
colnames(TablaOutliers) <- c("Cantidad de outliers","Mínimo","Máximo")
kable(TablaOutliers, format = "markdown", caption = "Tabla N°4: Outliers de la variable latitud en sedimentos marinos")
Tabla N°4: Outliers de la variable latitud en sedimentos marinos
Cantidad de outliers Mínimo Máximo
3908 15.31 80.81

CONCLUSIONES