##Erupciones volcánicas en el Holoceno Nombre, ubicación y tipo de volcanes activos en los últimos 10.000 años. Esta base de datos es útil para la exploración geológica porque permite analizar:La distribución geográfica y altitudinal de los volcanes; la relación entre los tipos de volcanes y su actividad y la composición de las rocas y su asociación con el entorno tectónico.
2.¿Existe una muestra? ¿Cuál es? Sí, la base de datos representa una muestra de volcanes. No es un listado completo de todos los volcanes del mundo, sino un subconjunto de ellos con datos específicos sobre su actividad, tipo, ubicación y otras características.
Parámetro: Si se estuviera estudiando la altitud promedio de todos los volcanes del mundo, la altitud real promedio de toda la población sería un parámetro. Estadístico: La altitud promedio de los volcanes en esta base de datos (muestra) es un estadístico, ya que se calcula con base en un subconjunto de la población total. Clasificación de variables:
Según su naturaleza:
*Cualitativas (categóricas): Name (nombre del volcán) Country (país) Region (región) Type (tipo de volcán) Activity Evidence (evidencia de actividad) Last Known Eruption (última erupción conocida) Dominant Rock Type (tipo de roca dominante) Tectonic Setting (ajuste tectónico) Cuantitativas (numéricas):
Latitude (latitud) → Continua Longitude (longitud) → Continua Elevation (Meters) (elevación en metros) → Continua
-Según su nivel de medición: *Nominal (categorías sin orden): Name, Country, Region, Type, Activity Evidence, Dominant Rock Type, Tectonic Setting
*Ordinal (categorías con orden, pero sin diferencias exactas): Last Known Eruption (las fechas de erupción son en diferentes escalas como BCE y CE, lo que implica un orden, pero no una diferencia numérica precisa)
*Intervalo (diferencias significativas, pero sin un cero absoluto): No parece haber ninguna variable de intervalo en esta base de datos.
*Razón (diferencias significativas con un cero absoluto): Latitude, Longitude, Elevation (Meters) (tienen un cero significativo y permiten cálculos como multiplicación o división).
library(dplyr)
##
## 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
library(ggplot2)
volcanes <- read.csv("C:/Users/mguzm/Desktop/ANALISIS/archive/database.csv")
#1Contextualización de la base de datos
str(volcanes)
## 'data.frame': 1508 obs. of 12 variables:
## $ Number : int 210010 210020 210030 210040 211001 211003 211004 211010 211020 211030 ...
## $ Name : chr "West Eifel Volcanic Field" "Chaine des Puys" "Olot Volcanic Field" "Calatrava Volcanic Field" ...
## $ Country : chr "Germany" "France" "Spain" "Spain" ...
## $ Region : chr "Mediterranean and Western Asia" "Mediterranean and Western Asia" "Mediterranean and Western Asia" "Mediterranean and Western Asia" ...
## $ Type : chr "Maar(s)" "Lava dome(s)" "Pyroclastic cone(s)" "Pyroclastic cone(s)" ...
## $ Activity.Evidence : chr "Eruption Dated" "Eruption Dated" "Evidence Credible" "Eruption Dated" ...
## $ Last.Known.Eruption: chr "8300 BCE" "4040 BCE" "Unknown" "3600 BCE" ...
## $ Latitude : num 50.2 45.8 42.2 38.9 43.2 ...
## $ Longitude : num 6.85 2.97 2.53 -4.02 10.87 ...
## $ Elevation..Meters. : int 600 1464 893 1117 500 800 949 458 1281 789 ...
## $ Dominant.Rock.Type : chr "Foidite" "Basalt / Picro-Basalt" "Trachybasalt / Tephrite Basanite" "Basalt / Picro-Basalt" ...
## $ Tectonic.Setting : chr "Rift Zone / Continental Crust (>25 km)" "Rift Zone / Continental Crust (>25 km)" "Intraplate / Continental Crust (>25 km)" "Intraplate / Continental Crust (>25 km)" ...
summary(volcanes)
## Number Name Country Region
## Min. :210010 Length:1508 Length:1508 Length:1508
## 1st Qu.:261158 Class :character Class :character Class :character
## Median :300015 Mode :character Mode :character Mode :character
## Mean :296656
## 3rd Qu.:342123
## Max. :390847
## Type Activity.Evidence Last.Known.Eruption Latitude
## Length:1508 Length:1508 Length:1508 Min. :-78.500
## Class :character Class :character Class :character 1st Qu.: -7.069
## Mode :character Mode :character Mode :character Median : 13.861
## Mean : 14.083
## 3rd Qu.: 41.749
## Max. : 85.608
## Longitude Elevation..Meters. Dominant.Rock.Type Tectonic.Setting
## Min. :-179.97 Min. :-4200.0 Length:1508 Length:1508
## 1st Qu.: -78.27 1st Qu.: 687.2 Class :character Class :character
## Median : 38.39 Median : 1464.0 Mode :character Mode :character
## Mean : 23.39 Mean : 1683.4
## 3rd Qu.: 138.58 3rd Qu.: 2352.2
## Max. : 179.58 Max. : 6879.0
str(volcanes)
## 'data.frame': 1508 obs. of 12 variables:
## $ Number : int 210010 210020 210030 210040 211001 211003 211004 211010 211020 211030 ...
## $ Name : chr "West Eifel Volcanic Field" "Chaine des Puys" "Olot Volcanic Field" "Calatrava Volcanic Field" ...
## $ Country : chr "Germany" "France" "Spain" "Spain" ...
## $ Region : chr "Mediterranean and Western Asia" "Mediterranean and Western Asia" "Mediterranean and Western Asia" "Mediterranean and Western Asia" ...
## $ Type : chr "Maar(s)" "Lava dome(s)" "Pyroclastic cone(s)" "Pyroclastic cone(s)" ...
## $ Activity.Evidence : chr "Eruption Dated" "Eruption Dated" "Evidence Credible" "Eruption Dated" ...
## $ Last.Known.Eruption: chr "8300 BCE" "4040 BCE" "Unknown" "3600 BCE" ...
## $ Latitude : num 50.2 45.8 42.2 38.9 43.2 ...
## $ Longitude : num 6.85 2.97 2.53 -4.02 10.87 ...
## $ Elevation..Meters. : int 600 1464 893 1117 500 800 949 458 1281 789 ...
## $ Dominant.Rock.Type : chr "Foidite" "Basalt / Picro-Basalt" "Trachybasalt / Tephrite Basanite" "Basalt / Picro-Basalt" ...
## $ Tectonic.Setting : chr "Rift Zone / Continental Crust (>25 km)" "Rift Zone / Continental Crust (>25 km)" "Intraplate / Continental Crust (>25 km)" "Intraplate / Continental Crust (>25 km)" ...
dim(volcanes)
## [1] 1508 12
summary(volcanes)
## Number Name Country Region
## Min. :210010 Length:1508 Length:1508 Length:1508
## 1st Qu.:261158 Class :character Class :character Class :character
## Median :300015 Mode :character Mode :character Mode :character
## Mean :296656
## 3rd Qu.:342123
## Max. :390847
## Type Activity.Evidence Last.Known.Eruption Latitude
## Length:1508 Length:1508 Length:1508 Min. :-78.500
## Class :character Class :character Class :character 1st Qu.: -7.069
## Mode :character Mode :character Mode :character Median : 13.861
## Mean : 14.083
## 3rd Qu.: 41.749
## Max. : 85.608
## Longitude Elevation..Meters. Dominant.Rock.Type Tectonic.Setting
## Min. :-179.97 Min. :-4200.0 Length:1508 Length:1508
## 1st Qu.: -78.27 1st Qu.: 687.2 Class :character Class :character
## Median : 38.39 Median : 1464.0 Mode :character Mode :character
## Mean : 23.39 Mean : 1683.4
## 3rd Qu.: 138.58 3rd Qu.: 2352.2
## Max. : 179.58 Max. : 6879.0
colnames(volcanes)
## [1] "Number" "Name" "Country"
## [4] "Region" "Type" "Activity.Evidence"
## [7] "Last.Known.Eruption" "Latitude" "Longitude"
## [10] "Elevation..Meters." "Dominant.Rock.Type" "Tectonic.Setting"
sapply(volcanes, class)
## Number Name Country Region
## "integer" "character" "character" "character"
## Type Activity.Evidence Last.Known.Eruption Latitude
## "character" "character" "character" "numeric"
## Longitude Elevation..Meters. Dominant.Rock.Type Tectonic.Setting
## "numeric" "integer" "character" "character"
#4.1. Cargar la librería necesaria para manipulación de datos
library(dplyr)
#4.2. Separar las variables numericas y categoricas
numericas <- select_if(volcanes, is.numeric)
categoricas <- select_if(volcanes, is.character)
#4.3. Analisis de variables numericas
summary(numericas)
## Number Latitude Longitude Elevation..Meters.
## Min. :210010 Min. :-78.500 Min. :-179.97 Min. :-4200.0
## 1st Qu.:261158 1st Qu.: -7.069 1st Qu.: -78.27 1st Qu.: 687.2
## Median :300015 Median : 13.861 Median : 38.39 Median : 1464.0
## Mean :296656 Mean : 14.083 Mean : 23.39 Mean : 1683.4
## 3rd Qu.:342123 3rd Qu.: 41.749 3rd Qu.: 138.58 3rd Qu.: 2352.2
## Max. :390847 Max. : 85.608 Max. : 179.58 Max. : 6879.0
#4.4.Contar los valores únicos en cada variable categórica
conteo_categorias <- sapply(categoricas, function(x) length(unique(x)))
print(conteo_categorias)
## Name Country Region Type
## 1478 100 19 33
## Activity.Evidence Last.Known.Eruption Dominant.Rock.Type Tectonic.Setting
## 7 399 12 12
#4.5. # Filtrar solo las variables categóricas con menos de 1000 valores únicos
categoricas_reducidas <- categoricas[, conteo_categorias < 1000]
#4.6. Crear tablas de frecuencia solo para las variables categóricas filtradas
tablas_categoricas <- lapply(categoricas_reducidas, table)
print(tablas_categoricas)
## $Country
##
## Algeria Algeria-Niger
## 3 1
## Antarctica Argentina
## 25 20
## Armenia Armenia-Azerbaijan
## 3 2
## Australia Bolivia
## 3 6
## Brazil Burma (Myanmar)
## 1 3
## Cameroon Canada
## 4 24
## Cape Verde Chad
## 2 4
## Chile Chile-Argentina
## 76 19
## Chile-Bolivia Chile-Peru
## 7 1
## China China-North Korea
## 11 1
## Colombia Colombia-Ecuador
## 16 1
## Comoros Costa Rica
## 2 10
## Djibouti Dominica
## 1 5
## DR Congo DR Congo-Rwanda
## 3 2
## Ecuador El Salvador
## 35 18
## El Salvador-Guatemala Equatorial Guinea
## 1 3
## Eritrea Eritrea-Djibouti
## 5 1
## Ethiopia Ethiopia-Djibouti
## 52 1
## Ethiopia-Eritrea Ethiopia-Eritrea-Djibouti
## 2 1
## Ethiopia-Kenya Fiji
## 1 3
## France Georgia
## 21 2
## Germany Greece
## 1 6
## Grenada Guatemala
## 2 22
## Guatemala-El Salvador Honduras
## 1 4
## Iceland India
## 32 2
## Indonesia Iran
## 139 7
## Italy Japan
## 16 112
## Japan - administered by Russia Kenya
## 16 22
## Madagascar Malaysia
## 5 1
## Mali Mexico
## 1 42
## Mexico-Guatemala Mongolia
## 1 5
## Netherlands New Zealand
## 2 29
## Nicaragua Niger
## 18 1
## Nigeria North Korea
## 1 1
## North Korea-South Korea Norway
## 1 2
## Panama Papua New Guinea
## 3 53
## Peru Philippines
## 16 50
## Portugal Russia
## 14 145
## Saint Kitts and Nevis Saint Lucia
## 2 1
## Saint Vincent and the Grenadines Samoa
## 1 2
## Saudi Arabia Solomon Islands
## 9 9
## South Africa South Korea
## 2 2
## Spain Sudan
## 8 4
## Syria Syria-Jordan-Saudi Arabia
## 2 1
## Taiwan Tanzania
## 4 7
## Tonga Turkey
## 20 10
## Uganda Uganda-Rwanda
## 6 1
## Undersea Features United Kingdom
## 25 13
## United States Vanuatu
## 173 14
## Vietnam Yemen
## 6 11
##
## $Region
##
## Africa and Red Sea Alaska
## 131 88
## Antarctica Atlantic Ocean
## 34 30
## Canada and Western USA Hawaii and Pacific Ocean
## 71 33
## Iceland and Arctic Ocean Indonesia
## 34 142
## Japan, Taiwan, Marianas Kamchatka and Mainland Asia
## 141 132
## Kuril Islands Mediterranean and Western Asia
## 46 44
## Melanesia and Australia México and Central America
## 80 120
## Middle East and Indian Ocean New Zealand to Fiji
## 46 60
## Philippines and SE Asia South America
## 62 197
## West Indies
## 17
##
## $Type
##
## Caldera Caldera(s) Complex Complex(es)
## 86 11 54 1
## Compound Cone(s) Crater rows Explosion crater(s)
## 14 1 6 2
## Fissure vent Fissure vent(s) Lava cone Lava cone(s)
## 2 16 3 1
## Lava dome Lava dome(s) Maar Maar(s)
## 12 38 8 13
## Pyroclastic cone Pyroclastic cone(s) Pyroclastic shield Shield
## 18 99 8 129
## Shield(s) Stratovolcano Stratovolcano(es) Stratovolcano?
## 35 597 121 4
## Subglacial Submarine Submarine(es) Tuff cone
## 6 116 2 3
## Tuff cone(s) Tuff ring(s) Unknown Volcanic field
## 9 1 3 88
## Volcanic field(s)
## 1
##
## $Activity.Evidence
##
## Eruption Dated Eruption Observed
## 1 298 568
## Evidence Credible Evidence Uncertain Unrest / Holocene
## 345 184 67
## Unrest / Pleistocene
## 45
##
## $Last.Known.Eruption
##
## 0 CE 1000 CE 1007 CE 104 BCE 10450 BCE 1050 BCE 1050 CE 1060 BCE
## 1 1 1 1 1 5 1 1
## 1060 CE 1075 CE 1080 CE 1090 CE 1100 CE 1150 BCE 1150 CE 1170 BCE
## 2 1 1 1 1 1 2 2
## 1180 BCE 1180 CE 1190 CE 120 CE 1200 BCE 1200 CE 1222 CE 1230 CE
## 1 2 1 1 3 2 1 1
## 1240 CE 1250 BCE 1250 CE 1253 CE 1256 CE 1260 CE 1270 CE 1280 BCE
## 1 2 2 1 1 1 2 1
## 1280 CE 1282 CE 1290 CE 130 BCE 1302 CE 1320 BCE 1320 CE 1340 CE
## 1 1 2 1 1 1 1 1
## 1341 CE 1350 BCE 1350 CE 1360 CE 1380 CE 140 CE 1450 CE 1454 CE
## 1 2 6 1 1 1 1 1
## 1477 CE 1490 CE 150 CE 1500 CE 1538 CE 1544 CE 1550 BCE 1550 CE
## 1 1 1 1 1 1 1 7
## 1560 CE 1564 CE 1580 CE 160 BCE 160 CE 1600 BCE 1600 CE 1606 CE
## 1 1 1 1 1 1 2 1
## 1630 CE 1631 CE 1640 CE 1641 CE 1650 CE 1652 CE 1659 CE 1660 CE
## 1 1 1 1 1 1 1 1
## 1690 CE 1699 CE 1700 CE 1708 CE 1710 CE 1720 CE 1728 CE 1730 CE
## 2 1 1 1 2 3 1 1
## 1739 CE 1740 CE 1750 CE 1755 CE 1766 CE 1770 CE 1773 CE 1776 CE
## 1 1 2 1 1 1 1 2
## 1785 CE 1786 CE 1787 CE 1790 BCE 1790 CE 1793 CE 1796 CE 1797 CE
## 2 2 1 1 2 1 2 1
## 180 CE 1800 CE 1801 CE 1802 CE 1810 CE 1812 CE 1813 CE 1814 CE
## 1 4 1 2 2 1 1 1
## 1818 CE 1820 CE 1822 CE 1824 CE 1825 CE 1828 CE 1830 CE 1835 CE
## 1 5 1 1 1 1 2 2
## 1839 CE 1840 CE 1846 CE 1847 CE 1848 CE 1850 CE 1853 CE 1854 CE
## 2 1 1 2 1 2 2 4
## 1855 CE 1857 CE 1859 CE 1860 CE 1861 CE 1863 CE 1865 CE 1866 CE
## 2 1 1 2 1 2 1 2
## 1867 CE 1868 CE 1869 CE 1872 CE 1873 CE 1874 CE 1875 CE 1876 CE
## 2 1 2 1 1 1 1 1
## 1877 CE 1878 CE 1880 CE 1881 CE 1882 CE 1883 CE 1884 CE 1885 CE
## 1 1 5 2 1 1 1 1
## 1886 CE 1888 CE 1890 BCE 1890 CE 1891 CE 1892 CE 1894 CE 1895 CE
## 2 3 1 3 1 2 1 2
## 1897 CE 1898 CE 1899 CE 190 BCE 1900 BCE 1900 CE 1901 CE 1903 CE
## 1 2 1 1 2 1 1 2
## 1904 CE 1905 CE 1906 CE 1907 CE 1908 CE 1909 CE 1910 CE 1911 CE
## 1 1 3 2 1 1 4 3
## 1912 CE 1913 CE 1914 CE 1915 CE 1916 CE 1917 CE 1918 CE 1919 CE
## 4 1 3 2 1 4 1 2
## 1920 CE 1921 CE 1923 CE 1924 CE 1926 CE 1928 CE 1929 CE 1931 CE
## 1 3 4 4 2 2 1 1
## 1932 CE 1933 CE 1935 CE 1936 CE 1937 CE 1938 CE 1939 CE 1940 CE
## 3 4 1 3 4 2 2 2
## 1943 CE 1944 CE 1945 CE 1946 CE 1950 BCE 1950 CE 1951 CE 1952 CE
## 1 2 1 1 1 2 3 6
## 1953 CE 1954 CE 1956 CE 1957 CE 1958 CE 1959 CE 1960 CE 1961 CE
## 3 2 2 6 1 1 5 1
## 1962 CE 1963 CE 1964 CE 1966 CE 1967 CE 1968 CE 1969 CE 1970 CE
## 2 1 1 2 3 4 3 3
## 1971 CE 1972 CE 1973 CE 1974 CE 1975 CE 1977 CE 1978 CE 1979 CE
## 3 4 2 5 2 6 2 5
## 1980 CE 1981 CE 1982 CE 1983 CE 1984 CE 1985 CE 1986 CE 1987 CE
## 1 3 1 2 4 4 3 3
## 1988 CE 1989 CE 1990 CE 1991 CE 1992 CE 1993 CE 1994 CE 1995 CE
## 3 4 4 2 4 6 2 6
## 1996 CE 1997 CE 1998 CE 1999 CE 200 CE 2000 BCE 2000 CE 2001 CE
## 8 3 2 5 3 2 8 4
## 2002 CE 2003 CE 2004 CE 2005 CE 2006 CE 2007 CE 2008 CE 2009 CE
## 6 4 5 5 5 9 12 9
## 2010 CE 2011 CE 2012 CE 2013 CE 2014 CE 2015 CE 2016 CE 2050 BCE
## 8 9 13 10 14 21 68 4
## 2080 BCE 210 BCE 210 CE 2120 BCE 220 BCE 2200 BCE 2220 BCE 2240 BCE
## 1 1 1 1 1 1 1 1
## 2260 BCE 230 BCE 2300 BCE 2450 BCE 2460 BCE 250 CE 258 BCE 260 CE
## 1 1 1 1 1 1 1 1
## 2790 BCE 2850 BCE 290 CE 2900 BCE 2950 BCE 2980 BCE 2990 BCE 300 BCE
## 1 1 2 1 1 1 1 2
## 300 CE 3000 BCE 3050 BCE 320 BCE 3250 BCE 3350 BCE 340 CE 3400 BCE
## 2 1 2 2 2 1 1 1
## 3450 BCE 3490 BCE 350 BCE 350 CE 3500 BCE 3550 BCE 3600 BCE 3740 BCE
## 1 1 1 2 2 2 1 1
## 3850 BCE 390 CE 3920 BCE 40 CE 400 BCE 400 CE 4000 BCE 4040 BCE
## 1 1 1 1 1 2 1 1
## 4050 BCE 410 BCE 4100 BCE 4360 BCE 440 CE 442 BCE 4450 BCE 4470 BCE
## 2 1 1 1 1 1 2 1
## 4500 BCE 4550 BCE 4570 BCE 480 CE 4890 BCE 4900 BCE 4920 BCE 4946 BCE
## 1 2 1 1 1 1 1 1
## 50 BCE 50 CE 500 BCE 500 CE 5050 BCE 5060 BCE 5180 BCE 520 BCE
## 8 1 1 1 4 1 1 1
## 5220 BCE 5250 BCE 5310 BCE 5350 BCE 5390 BCE 550 BCE 550 CE 5550 BCE
## 1 1 1 2 1 5 2 4
## 560 CE 5610 BCE 5750 BCE 5800 BCE 5830 BCE 590 BCE 6050 BCE 6200 BCE
## 1 1 2 1 1 1 3 1
## 6250 BCE 640 CE 6440 BCE 648 CE 650 CE 6550 BCE 6650 BCE 680 CE
## 1 1 1 1 4 1 2 1
## 6850 BCE 6880 BCE 6890 BCE 690 CE 70 CE 700 BCE 7050 BCE 7480 BCE
## 1 1 1 1 1 1 2 1
## 750 BCE 750 CE 7550 BCE 7600 BCE 778 BCE 800 BCE 8040 BCE 8050 BCE
## 2 1 2 1 1 3 1 3
## 8060 BCE 8300 BCE 8350 BCE 837 CE 838 CE 8400 BCE 847 CE 850 BCE
## 1 1 1 1 1 1 1 1
## 850 CE 867 CE 870 CE 885 CE 886 CE 900 BCE 915 CE 920 CE
## 2 1 1 1 1 1 1 1
## 930 BCE 950 BCE 950 CE 9540 BCE 960 BCE 960 CE Unknown
## 1 1 6 1 1 1 637
##
## $Dominant.Rock.Type
##
##
## 53
## Andesite / Basaltic Andesite
## 578
## Basalt / Picro-Basalt
## 493
## Dacite
## 94
## Foidite
## 15
## No Data
## 58
## Phono-tephrite / Tephri-phonolite
## 3
## Phonolite
## 9
## Rhyolite
## 66
## Trachyandesite / Basaltic Trachyandesite
## 30
## Trachybasalt / Tephrite Basanite
## 73
## Trachyte / Trachydacite
## 36
##
## $Tectonic.Setting
##
##
## 7
## Intraplate / Continental Crust (>25 km)
## 156
## Intraplate / Intermediate Crust (15-25 km)
## 5
## Intraplate / Oceanic Crust (< 15 km)
## 31
## Rift Zone / Continental Crust (>25 km)
## 109
## Rift Zone / Intermediate Crust (15-25 km)
## 43
## Rift Zone / Oceanic Crust (< 15 km)
## 101
## Subduction Zone / Continental Crust (>25 km)
## 762
## Subduction Zone / Crust Thickness Unknown
## 83
## Subduction Zone / Intermediate Crust (15-25 km)
## 78
## Subduction Zone / Oceanic Crust (< 15 km)
## 132
## Unknown
## 1
altos <- filter(volcanes, `Elevation..Meters.` > 2000)
italia <- filter(volcanes, Country == "Italy")
total_na <- sum(is.na(volcanes))
colSums(is.na(volcanes))
## Number Name Country Region
## 0 0 0 0
## Type Activity.Evidence Last.Known.Eruption Latitude
## 0 0 0 0
## Longitude Elevation..Meters. Dominant.Rock.Type Tectonic.Setting
## 0 0 0 0
boxplot(volcanes$`Elevation..Meters.`, main = "Valores Atípicos en Elevación", ylab = "Metros")
Este gráfico representa la distribución de la elevación de los volcanes
en metros y permite identificar valores atípicos en la base de datos. A
continuación, se detallan los principales aspectos:
##8.Grafico de barras
head(data)
##
## 1 function (..., list = character(), package = NULL, lib.loc = NULL,
## 2 verbose = getOption("verbose"), envir = .GlobalEnv, overwrite = TRUE)
## 3 {
## 4 fileExt <- function(x) {
## 5 db <- grepl("\\\\.[^.]+\\\\.(gz|bz2|xz)$", x)
## 6 ans <- sub(".*\\\\.", "", x)
str(data)
## function (..., list = character(), package = NULL, lib.loc = NULL, verbose = getOption("verbose"),
## envir = .GlobalEnv, overwrite = TRUE)
data <- read.csv("C:/Users/mguzm/Desktop/ANALISIS/archive/database.csv", stringsAsFactors = TRUE)
# Cargar librerías necesarias
library(ggplot2)
library(dplyr)
# Copia de seguridad de los datos originales
data_clean <- data
# Limpiar la columna Type para evitar duplicados con diferentes formatos
data_clean$Type <- gsub("\\(.*\\)", "", data_clean$Type) # Elimina paréntesis y su contenido
data_clean$Type <- gsub("\\?", "", data_clean$Type) # Elimina signos de interrogación
data_clean$Type <- trimws(data_clean$Type) # Elimina espacios en blanco extra
# Verificar valores únicos después de la limpieza
unique(data_clean$Type)
## [1] "Maar" "Lava dome" "Pyroclastic cone"
## [4] "Explosion crater" "Caldera" "Stratovolcano"
## [7] "Complex" "Submarine" "Shield"
## [10] "Lava cone" "Volcanic field" "Fissure vent"
## [13] "Tuff cone" "Pyroclastic shield" "Compound"
## [16] "Unknown" "Crater rows" "Cone"
## [19] "Tuff ring" "Subglacial"
# Generar gráfico de barras corregido
ggplot(data_clean, aes(x = Type, fill = Type)) +
geom_bar() +
theme_minimal() +
labs(title = "Distribución de Tipos de Volcanes",
x = "Tipo de Volcán",
y = "Frecuencia") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
Muestra cuántos volcanes hay de cada tipo (estratovolcán, caldera, cono de escoria, etc.).
##9.Grafico Circular
library(ggplot2)
library(dplyr)
library(RColorBrewer)
data_clean <- data
data_clean$Region <- trimws(data_clean$Region)
volcanes_region <- data_clean %>%
group_by(Region) %>%
summarise(Frecuencia = n()) %>%
arrange(desc(Frecuencia))
ggplot(volcanes_region, aes(x = "", y = Frecuencia, fill = Region)) +
geom_bar(stat = "identity", width = 1, color = "white") +
coord_polar(theta = "y") +
theme_minimal() +
labs(title = "Proporción de Volcanes por Región",
x = NULL, y = NULL) +
theme(axis.text = element_blank(),
axis.ticks = element_blank(),
panel.grid = element_blank()) +
scale_fill_viridis_d(option = "plasma")
Permite ver qué regiones tienen más volcanes, lo que es clave en
estudios geológicos.
```