Variable cuantitativa continua
Latitud
Importamos el archivo “archive (2)/Earthquakes.csv” desde una ruta local y lo almacena en el Datos, usando espacios o tabulaciones como separador. Luego, la función str(Datos) muestra la estructura del data frame, indicando tipos de datos y ejemplos de sus columnas.
Datos <- read.csv("C:/Users/Estefania Ibaza/Desktop/UCE/CUARTO/GRUPALSISMOS/CODIGOSISMOS/Earthquakes.csv", header = TRUE, sep=",", dec=".")
str(Datos)## 'data.frame': 17805 obs. of 22 variables:
## $ time : chr "2024-10-31T01:32:40.503Z" "2024-10-30T23:51:31.217Z" "2024-10-29T02:35:27.930Z" "2024-10-28T13:08:40.107Z" ...
## $ latitude : num 29.86 28.21 4.72 27.87 32.75 ...
## $ longitude : num 92.2 67.1 96.2 94 90.4 ...
## $ depth : num 10 10 42.1 36.3 10 ...
## $ mag : num 4.4 4.3 4.6 4.6 4 4.6 4.7 4.3 5.3 4.4 ...
## $ magType : chr "mb" "mb" "mb" "mb" ...
## $ nst : int 35 36 27 62 22 44 39 34 80 27 ...
## $ gap : num 89 195 91 98 79 170 169 105 65 140 ...
## $ dmin : num 6.45 9.37 0.87 6.69 6.64 ...
## $ rms : num 0.82 0.72 0.55 0.65 0.72 0.74 0.81 0.54 0.92 0.9 ...
## $ net : chr "us" "us" "us" "us" ...
## $ id : chr "us7000np4h" "us7000np47" "us7000nnqs" "us7000nnml" ...
## $ updated : chr "2024-10-31T01:54:50.040Z" "2024-10-31T00:07:19.040Z" "2024-10-29T03:36:02.040Z" "2024-10-29T04:19:35.951Z" ...
## $ place : chr "113 km ENE of Lhasa, China" "64 km NE of Khuzdar, Pakistan" "55 km S of Reuleuet, Indonesia" "35 km NNE of Ziro, India" ...
## $ type : chr "earthquake" "earthquake" "earthquake" "earthquake" ...
## $ horizontalError: num 7.45 12.2 5.1 8.9 9.39 ...
## $ depthError : num 1.88 1.99 8.27 7.33 1.98 ...
## $ magError : num 0.114 0.092 0.146 0.078 0.139 0.078 0.097 0.107 0.11 0.102 ...
## $ magNst : int 22 33 14 49 14 49 32 25 8 28 ...
## $ status : chr "reviewed" "reviewed" "reviewed" "reviewed" ...
## $ locationSource : chr "us" "us" "us" "us" ...
## $ magSource : chr "us" "us" "us" "us" ...
Cálculo de los intervalos mediante la regla de Sturges
## [1] 15
## [1] 1.7930 4.0394 6.2858 8.5322 10.7786 13.0250 15.2714 17.5178 19.7642
## [10] 22.0106 24.2570 26.5034 28.7498 30.9962 33.2426
## [1] 4.0394 6.2858 8.5322 10.7786 13.0250 15.2714 17.5178 19.7642 22.0106
## [10] 24.2570 26.5034 28.7498 30.9962 33.2426 35.4890
## [1] 2.92 5.16 7.41 9.66 11.90 14.15 16.39 18.64 20.89 23.13 25.38 27.63
## [13] 29.87 32.12 34.37
ni <- numeric(length(Li))
for (i in 1:length(Li)) {
ni[i] <- sum(Latitud >= Li[i] & Latitud < Ls[i])
}
ni[length(Li)] <- sum(Latitud >= Li[length(Li)] & Latitud <= max)
sum(ni) ## [1] 17805
## [1] 100
Ni_asc <- cumsum(ni)
Ni_dsc <- rev(cumsum(rev(ni)))
Hi_asc <- round(cumsum(hi), 2)
Hi_dsc <- round(rev(cumsum(rev(hi))), 2)
TDFLatitud <-data.frame(Li, Ls, MC, ni, hi, Ni_asc, Ni_dsc, Hi_asc, Hi_dsc)
TDFLatitudAgregar Totales, para una mejor visualización de la tabla
total_ni <- sum(ni)
total_hi <- 100
TDFLatitudCompleto<-rbind(TDFLatitud, data.frame(Li="Total",
Ls=" ", MC=" ",ni=total_ni, hi=total_hi, Ni_asc=" ", Ni_dsc=" ",
Hi_asc=" ", Hi_dsc=" "))
print(TDFLatitudCompleto)## Li Ls MC ni hi Ni_asc Ni_dsc Hi_asc Hi_dsc
## 1 1.793 4.0394 2.92 3069 17.2367313 3069 17805 17.24 100
## 2 4.0394 6.2858 5.16 1900 10.6711598 4969 14736 27.91 82.76
## 3 6.2858 8.5322 7.41 2085 11.7101938 7054 12836 39.62 72.09
## 4 8.5322 10.7786 9.66 1209 6.7902275 8263 10751 46.41 60.38
## 5 10.7786 13.025 11.9 879 4.9368155 9142 9542 51.35 53.59
## 6 13.025 15.2714 14.15 610 3.4260039 9752 8663 54.77 48.65
## 7 15.2714 17.5178 16.39 164 0.9210896 9916 8053 55.69 45.23
## 8 17.5178 19.7642 18.64 210 1.1794440 10126 7889 56.87 44.31
## 9 19.7642 22.0106 20.89 307 1.7242348 10433 7679 58.6 43.13
## 10 22.0106 24.257 23.13 882 4.9536647 11315 7372 63.55 41.4
## 11 24.257 26.5034 25.38 903 5.0716091 12218 6490 68.62 36.45
## 12 26.5034 28.7498 27.63 1105 6.2061219 13323 5587 74.83 31.38
## 13 28.7498 30.9962 29.87 1387 7.7899466 14710 4482 82.62 25.17
## 14 30.9962 33.2426 32.12 925 5.1951699 15635 3095 87.81 17.38
## 15 33.2426 35.489 34.37 2170 12.1875878 17805 2170 100 12.19
## 16 Total 17805 100.0000000
## Warning: package 'gt' was built under R version 4.4.3
## Warning: package 'dplyr' was built under R version 4.4.3
##
## Adjuntando el paquete: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
# Crear la tabla
tabla_Latitud<-TDFLatitudCompleto %>%
gt() %>%
tab_header(
title = md("*Tabla N°12*"),
subtitle = md("**Tabla de distribución de Frecuencias simples y acumuladas
de la Latitud de los Sismos en el Subcontinente Indio (2000-2024)**")
) %>%
tab_source_note(
source_note = md("Autor:Grupo1")
) %>%
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"
) %>%
tab_style(
style = cell_text(weight = "bold"),
locations = cells_body(
rows = Li == "Total"
)
)
tabla_Latitud| Tabla N°12 | ||||||||
| Tabla de distribución de Frecuencias simples y acumuladas de la Latitud de los Sismos en el Subcontinente Indio (2000-2024) | ||||||||
| Li | Ls | MC | ni | hi | Ni_asc | Ni_dsc | Hi_asc | Hi_dsc |
|---|---|---|---|---|---|---|---|---|
| 1.793 | 4.0394 | 2.92 | 3069 | 17.2367313 | 3069 | 17805 | 17.24 | 100 |
| 4.0394 | 6.2858 | 5.16 | 1900 | 10.6711598 | 4969 | 14736 | 27.91 | 82.76 |
| 6.2858 | 8.5322 | 7.41 | 2085 | 11.7101938 | 7054 | 12836 | 39.62 | 72.09 |
| 8.5322 | 10.7786 | 9.66 | 1209 | 6.7902275 | 8263 | 10751 | 46.41 | 60.38 |
| 10.7786 | 13.025 | 11.9 | 879 | 4.9368155 | 9142 | 9542 | 51.35 | 53.59 |
| 13.025 | 15.2714 | 14.15 | 610 | 3.4260039 | 9752 | 8663 | 54.77 | 48.65 |
| 15.2714 | 17.5178 | 16.39 | 164 | 0.9210896 | 9916 | 8053 | 55.69 | 45.23 |
| 17.5178 | 19.7642 | 18.64 | 210 | 1.1794440 | 10126 | 7889 | 56.87 | 44.31 |
| 19.7642 | 22.0106 | 20.89 | 307 | 1.7242348 | 10433 | 7679 | 58.6 | 43.13 |
| 22.0106 | 24.257 | 23.13 | 882 | 4.9536647 | 11315 | 7372 | 63.55 | 41.4 |
| 24.257 | 26.5034 | 25.38 | 903 | 5.0716091 | 12218 | 6490 | 68.62 | 36.45 |
| 26.5034 | 28.7498 | 27.63 | 1105 | 6.2061219 | 13323 | 5587 | 74.83 | 31.38 |
| 28.7498 | 30.9962 | 29.87 | 1387 | 7.7899466 | 14710 | 4482 | 82.62 | 25.17 |
| 30.9962 | 33.2426 | 32.12 | 925 | 5.1951699 | 15635 | 3095 | 87.81 | 17.38 |
| 33.2426 | 35.489 | 34.37 | 2170 | 12.1875878 | 17805 | 2170 | 100 | 12.19 |
| Total | 17805 | 100.0000000 | ||||||
| Autor:Grupo1 | ||||||||
Realizamos el histograma de la variable para extraer los breaks y asi conocer los nuevos límites.
histoLatitud<-hist(Latitud,
main= "Gráfica N°39:Distribución de frecuencia de Latitud \nde los sismos en el Subcontiente Indio",
xlab= " Latitud (°)",
ylab= "Cantidad", col="blue",
las=2)## [1] 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36
## [1] 17805
## [1] 100
Niasc <- cumsum(ni)
Nidsc <- rev(cumsum(rev(ni)))
Hiasc <- round(cumsum(hi), 2)
Hidsc <- round(rev(cumsum(rev(hi))), 2)
TDFLatitudes<-data.frame(LimInf, LimSup, Mc, ni, hi, Niasc, Nidsc, Hiasc, Hidsc)
TDFLatitudesAgregar Totales, para una mejor visualización de la tabla
totalni <- sum(ni)
totalhi <- 100
TDFLatitudesCompleto<-rbind(TDFLatitudes, data.frame(LimInf="Total",
LimSup=" ", Mc=" ",ni=totalni, hi=totalhi, Niasc=" ", Nidsc=" ",
Hiasc=" ", Hidsc=" "))
print(TDFLatitudesCompleto)## LimInf LimSup Mc ni hi Niasc Nidsc Hiasc Hidsc
## 1 0 2 1 389 2.1847796 389 17805 2.18 100
## 2 2 4 3 2657 14.9227745 3046 17416 17.11 97.82
## 3 4 6 5 1824 10.2443134 4870 14759 27.35 82.89
## 4 6 8 7 1765 9.9129458 6635 12935 37.26 72.65
## 5 8 10 9 1003 5.6332491 7638 11170 42.9 62.74
## 6 10 12 11 1112 6.2454367 8750 10167 49.14 57.1
## 7 12 14 13 796 4.4706543 9546 9055 53.61 50.86
## 8 14 16 15 252 1.4153328 9798 8259 55.03 46.39
## 9 16 18 17 139 0.7806796 9937 8007 55.81 44.97
## 10 18 20 19 229 1.2861556 10166 7868 57.1 44.19
## 11 20 22 21 267 1.4995788 10433 7639 58.6 42.9
## 12 22 24 23 809 4.5436675 11242 7372 63.14 41.4
## 13 24 26 25 770 4.3246279 12012 6563 67.46 36.86
## 14 26 28 27 1006 5.6500983 13018 5793 73.11 32.54
## 15 28 30 29 884 4.9648975 13902 4787 78.08 26.89
## 16 30 32 31 1108 6.2229711 15010 3903 84.3 21.92
## 17 32 34 33 994 5.5827015 16004 2795 89.88 15.7
## 18 34 36 35 1801 10.1151362 17805 1801 100 10.12
## 19 Total 17805 100.0000000
library(gt)
library(dplyr)
# Crear la tabla
tablaLatitudes<-TDFLatitudesCompleto %>%
gt() %>%
tab_header(
title = md("*Tabla N°13*"),
subtitle = md("**Tabla de distribucion de Frecuencias simples y acumuladas
de Latitud de los Sismos en el Subcontinente Indio (2000-2024)**")
) %>%
tab_source_note(
source_note = md("Autor:Grupo1")
) %>%
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"
) %>%
tab_style(
style = cell_text(weight = "bold"),
locations = cells_body(
rows = LimInf == "Total"
)
)
tablaLatitudes| Tabla N°13 | ||||||||
| Tabla de distribucion de Frecuencias simples y acumuladas de Latitud de los Sismos en el Subcontinente Indio (2000-2024) | ||||||||
| LimInf | LimSup | Mc | ni | hi | Niasc | Nidsc | Hiasc | Hidsc |
|---|---|---|---|---|---|---|---|---|
| 0 | 2 | 1 | 389 | 2.1847796 | 389 | 17805 | 2.18 | 100 |
| 2 | 4 | 3 | 2657 | 14.9227745 | 3046 | 17416 | 17.11 | 97.82 |
| 4 | 6 | 5 | 1824 | 10.2443134 | 4870 | 14759 | 27.35 | 82.89 |
| 6 | 8 | 7 | 1765 | 9.9129458 | 6635 | 12935 | 37.26 | 72.65 |
| 8 | 10 | 9 | 1003 | 5.6332491 | 7638 | 11170 | 42.9 | 62.74 |
| 10 | 12 | 11 | 1112 | 6.2454367 | 8750 | 10167 | 49.14 | 57.1 |
| 12 | 14 | 13 | 796 | 4.4706543 | 9546 | 9055 | 53.61 | 50.86 |
| 14 | 16 | 15 | 252 | 1.4153328 | 9798 | 8259 | 55.03 | 46.39 |
| 16 | 18 | 17 | 139 | 0.7806796 | 9937 | 8007 | 55.81 | 44.97 |
| 18 | 20 | 19 | 229 | 1.2861556 | 10166 | 7868 | 57.1 | 44.19 |
| 20 | 22 | 21 | 267 | 1.4995788 | 10433 | 7639 | 58.6 | 42.9 |
| 22 | 24 | 23 | 809 | 4.5436675 | 11242 | 7372 | 63.14 | 41.4 |
| 24 | 26 | 25 | 770 | 4.3246279 | 12012 | 6563 | 67.46 | 36.86 |
| 26 | 28 | 27 | 1006 | 5.6500983 | 13018 | 5793 | 73.11 | 32.54 |
| 28 | 30 | 29 | 884 | 4.9648975 | 13902 | 4787 | 78.08 | 26.89 |
| 30 | 32 | 31 | 1108 | 6.2229711 | 15010 | 3903 | 84.3 | 21.92 |
| 32 | 34 | 33 | 994 | 5.5827015 | 16004 | 2795 | 89.88 | 15.7 |
| 34 | 36 | 35 | 1801 | 10.1151362 | 17805 | 1801 | 100 | 10.12 |
| Total | 17805 | 100.0000000 | ||||||
| Autor:Grupo1 | ||||||||
hist(Latitud,main="Gráfica N°40: Distribucion de la frecuecnia de Latitud \nde los sismos del Subcontinente Indio (Local)",
ylab="Cantidad",
xlab="Latitud (°)",
col="blue")hist(Latitud,main="Gráfica N°41: Distribucion de la frecuecnia de Latitud \nde los sismos del Subcontinente Indio (Global)",
ylab="Cantidad",
xlab="Latitud (°)",
col="blue", ylim = c(0,length(Latitud)))barplot(hi,space = 0,
main="Gráfica N°42:Distribución del porcentaje de Latitud \nde los sismos del Subcontinente Indio (Local)",
col="blue",
xlab = "Latitud (°)",
ylab = "Porcentaje (%)",
names.arg =TDFLatitudes$Mc)barplot(hi,space = 0,
main="Gráfica N°43:Distribución del porcentaje de Latitud \nde los sismos del Subcontinente Indio (Global)",
col="blue",
xlab = "Latitud (°)",
ylab = "Porcentaje (%)",
names.arg =TDFLatitudes$Mc,
ylim = c(0,100)
)TDFLatitudes <- na.omit(TDFLatitudes)
# Verifica longitudes antes de graficar
if(length(TDFLatitudes$LimInf) == length(TDFLatitudes$Nidsc)) {
plot(TDFLatitudes$LimInf, TDFLatitudes$Nidsc,
main = "Gráfica N°44: Ojivas combinadas de Latitud\nde los sismos del Subcontinente Indio (2000–2024)",
xlab = "Latitud (°)",
ylab = "Cantidad",
col = "blue",
type = "b")
# Agrega segunda ojiva solo si longitudes son iguales
if(length(TDFLatitudes$LimSup) == length(TDFLatitudes$Niasc)) {
lines(TDFLatitudes$LimSup, TDFLatitudes$Niasc, col = "black", type = "b")
}
legend("right",
legend = c("Ojiva descendente", "Ojiva ascendente"),
col = c("blue", "black"),pch = 1,lty = 1,cex = 0.7)
} # Verificamos que los vectores estén completos y sean compatibles
if(length(LimInf) == length(Hidsc) && length(LimSup) == length(Hiasc)) {
# Si hay NAs, los eliminamos
datos1 <- na.omit(data.frame(LimInf, Hidsc))
datos2 <- na.omit(data.frame(LimSup, Hiasc))
plot(datos1$LimInf, datos1$Hidsc,
main = "Gráfica N°45: Ojivas combinadas de Latitud\nde los sismos del Subcontinente Indio (2000–2024)",
xlab = "Latitud (°)",
ylab = "Porcentaje (%)",
col = "black",
type = "b")
# Añadir la segunda línea
lines(datos2$LimSup, datos2$Hiasc, col = "blue", type = "b")
# Leyenda
legend("right",
legend = c("Ojiva descendente", "Ojiva ascendente"),
col = c("black", "blue"), pch = 1, lty = 1,cex = 0.6)
} Caja<-boxplot(Latitud,horizontal = T,
col = "skyblue",
main="Gráfica N°46:Distribución de la cantidad de Latitud \nde los sismos del Subcontinente Indio (2000-2024)",
xlab="Latitud (°)")## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.793 5.372 12.504 16.732 28.854 35.489
´
## [1] 16.73156
## [1] 12.504
## [1] 11.92371
## [1] 71.26481
## Warning: package 'e1071' was built under R version 4.4.3
## [1] 0.2520928
## [1] -1.565396
Variable<-c("Latitud")
TablaIndicadores<-data.frame(Variable,ri,rs,round(x,2),Me,round(sd,2), round(CV,2), round(As,2),round(K,2))
colnames(TablaIndicadores)<-c("Variable","minimo","máximo","x","Me","sd","Cv (%)","As","K")
library(knitr)
kable(TablaIndicadores, format = "markdown", caption = "Tabla N°14. Indicadores estadíticos de la variable Latitud (°)")## Warning in attr(x, "align"): 'xfun::attr()' está en desuso.
## Utilizar 'xfun::attr2()' en su lugar.
## Ver help("Deprecated")
## Warning in attr(x, "format"): 'xfun::attr()' está en desuso.
## Utilizar 'xfun::attr2()' en su lugar.
## Ver help("Deprecated")
| Variable | minimo | máximo | x | Me | sd | Cv (%) | As | K |
|---|---|---|---|---|---|---|---|---|
| Latitud | 1.793 | 35.489 | 16.73 | 12.504 | 11.92 | 71.26 | 0.25 | -1.57 |
La variable latitud del subcontinente indio fluctúa entre 1.793° y 35.489°, con una media aproximada de 16.731° y una desviación estándar de 11.93°. El conjunto de datos es heterogéneo y muestra una acumulación de valores tanto hacia la izquierda como hacia la derecha de la variable, lo que sugiere una posible distribución bimodal o dispersa. Por lo antes mencionado, el comportamiento de la variable puede considerarse beneficioso, ya que la heterogeneidad indica que los sismos ocurren en diversas zonas latitudinales del subcontinente, es decir, no se concentran en una única región. Además, la ausencia de valores atípicos señala que los datos son consistentes y no presentan registros anómalos que puedan distorsionar el análisis estadístico.