Librerias requeridas
library(titanic)
## Warning: package 'titanic' was built under R version 4.0.2
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.0.2
library(corrplot)
## Warning: package 'corrplot' was built under R version 4.0.2
## corrplot 0.84 loaded
Carga de data
data=titanic_train
Edad de los pasajeros
summary(data$Age)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 0.42 20.12 28.00 29.70 38.00 80.00 177
boxplot(data$Age, horizontal = TRUE, col ="skyblue", main="Edad")

Género de los pasajeros
genero=data.frame(table(data$Sex))
names(genero) <- c("Género", "Frecuencia")
ggplot(genero, aes(Género,Frecuencia)) + geom_bar(stat = 'identity',fill='skyblue') + ggtitle("Género")

Tarifas
summary(data$Fare)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 7.91 14.45 32.20 31.00 512.33
hist(data$Fare, main = "Tarifas de los pasajeros")

Clase de los pasajeros
clase=data.frame(table(data$Pclass))
names(clase) <- c("Clase", "Frecuencia")
ggplot(clase, aes(Clase,Frecuencia)) + geom_bar(stat = 'identity',fill='skyblue') + ggtitle("Clase")

Supervivientes
sobrevivientes= data.frame(table(data$Survived), row.names = c("muriĂ³","viviĂ³"))
names(sobrevivientes) <- c("SobreviviĂ³", "Frecuencia")
ggplot(sobrevivientes, aes(SobreviviĂ³,Frecuencia)) + geom_bar(stat = 'identity',fill='skyblue') + ggtitle("Sobrevivientes")

Edad vs Tarifa
edad= data$Age
tarifa= data$Fare
edadytarifa <- matrix(c(edad, tarifa), 891,2)
mdcor <- round(cor(edadytarifa, method = 'pearson', use = "complete.obs"),5)
corrplot(mdcor)

Clase vs Género
ggplot(data, aes(x=Pclass))+ geom_histogram(fill='skyblue',bins=5) + facet_wrap(~Sex)

Género vs Supervivencia
ggplot(data, aes(x=Survived))+ geom_histogram(fill='skyblue',bins=3) + facet_wrap(~Sex)

Edad vs Supervivencia
ggplot(data, aes(x=Age))+ geom_density(fill='skyblue',bins=50) + facet_wrap(~Survived)
## Warning: Ignoring unknown parameters: bins
## Warning: Removed 177 rows containing non-finite values (stat_density).

Clase vs Supervivencia
ggplot(data, aes(x=Pclass))+ geom_bar(fill='skyblue') + facet_wrap(~Survived)
