library(tidyverse)
## -- Attaching packages ------------------------------------------------------- tidyverse 1.2.1 --
## v ggplot2 3.1.0 v purrr 0.2.5
## v tibble 1.4.2 v dplyr 0.7.6
## v tidyr 0.8.2 v stringr 1.3.1
## v readr 1.1.1 v forcats 0.3.0
## -- Conflicts ---------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(titanic)
library(ggplot2)
library(dplyr)
df <- dplyr::bind_rows(titanic::titanic_test,
titanic::titanic_train)
df <- as_tibble(df)
filter(df, Survived == 1)
total_vivos <- filter(df, Survived == 1)
filter(df, Age < 15)
niñes_total <- filter(df, Age < 15)
En el barco iban
ggplot(df) +
geom_count(mapping = aes(x = Sex, y = Pclass, color = factor (..n..))) +
ggtitle("Total de pasajeros por sexo y clase")
ggplot(niñes_total) +
geom_bar(mapping = aes(x = Survived, fill = factor(Pclass))) +
ggtitle("Infantes sobrevivientes y muertos por clase")
## Warning: Removed 31 rows containing non-finite values (stat_count).
ggplot(df) +
geom_jitter(mapping = aes(x = Fare, y = Sex, color = factor(Survived))) +
ggtitle("Muertos y sobrevivientes según precio del ticket y sexo")
## Warning: Removed 1 rows containing missing values (geom_point).
ggplot(df) +
geom_jitter(mapping = aes(x = Sex, y = Pclass, color = factor (Survived))) +
ggtitle("Sobrevivientes y muertos por clase y sexo")
ggplot(data = df, mapping = aes(x = Pclass, fill = factor (Sex))) +
geom_bar() +
facet_wrap(~ Survived) +
ggtitle("Cantidad de muertos y sobrevivientes según sexo y clase")