load("C:/Users/Vaio/OneDrive/Área de Trabalho/Titanic.RData")
a-classe
b-Idade
c-Sexo
d-Sobreviveu
table(Titanic$Classe)
##
## Tripulação Primeira Segunda Terceira
## 885 324 285 706
table(Titanic$Idade)
##
## criança adulto
## 109 2091
table(Titanic$Sexo)
##
## Feminino Masculino
## 470 1730
table(Titanic$Sobreviveu)
##
## Não sobreviveu Sobreviveu
## 1490 710
table(Titanic$Classe,Titanic$Sobreviveu)
##
## Não sobreviveu Sobreviveu
## Tripulação 673 212
## Primeira 122 202
## Segunda 167 118
## Terceira 528 178
table(Titanic$Idade,Titanic$Sobreviveu)
##
## Não sobreviveu Sobreviveu
## criança 52 57
## adulto 1438 653
table(Titanic$Sexo,Titanic$Sobreviveu)
##
## Não sobreviveu Sobreviveu
## Feminino 126 344
## Masculino 1364 366
tabela1<-table(Titanic$Classe,Titanic$Sobreviveu)
tabela2<-table(Titanic$Idade,Titanic$Sobreviveu)
tabela3<-table(Titanic$Sexo,Titanic$Sobreviveu)
tabela4<-table(Titanic$Sobreviveu)
tabela5<-table(Titanic$Sobreviveu,Titanic$Sexo)
summary(Titanic$Sobreviveu)
## Não sobreviveu Sobreviveu
## 1490 710
round(prop.table(tabela4)*100,2)
##
## Não sobreviveu Sobreviveu
## 67.73 32.27
prop.table(tabela3)*100
##
## Não sobreviveu Sobreviveu
## Feminino 5.727273 15.636364
## Masculino 62.000000 16.636364
round(prop.table(tabela3,1)*100,2)
##
## Não sobreviveu Sobreviveu
## Feminino 26.81 73.19
## Masculino 78.84 21.16
prop.table(tabela2)*100
##
## Não sobreviveu Sobreviveu
## criança 2.363636 2.590909
## adulto 65.363636 29.681818
round(prop.table(tabela2,1)*100,2)
##
## Não sobreviveu Sobreviveu
## criança 47.71 52.29
## adulto 68.77 31.23
prop.table(tabela1)*100
##
## Não sobreviveu Sobreviveu
## Tripulação 30.590909 9.636364
## Primeira 5.545455 9.181818
## Segunda 7.590909 5.363636
## Terceira 24.000000 8.090909
round(prop.table(tabela1,1)*100,2)
##
## Não sobreviveu Sobreviveu
## Tripulação 76.05 23.95
## Primeira 37.65 62.35
## Segunda 58.60 41.40
## Terceira 74.79 25.21
barplot(tabela4,
beside=TRUE,
col=c("blue","green"),
main = "GRÁFICO I - SOBREVIVENTES",
ylim = c(0,2200),ylab="Qtde de Pessoas",legend.text = TRUE)
barplot(tabela3,
beside=TRUE,
col=c("red","blue"),
main = "GRÁFICO II - SOBREVIVENTES POR SEXO",
ylim = c(0,2200),ylab="Qtde de Pessoas",legend.text = TRUE)
### Atividade 13- Você poderia construir uma outra visualização de dados (além dessas duas)? Qual gráfico você sugere?
library(forcats)
library(ggpubr)
## Loading required package: ggplot2
library(ggplot2)
tabela6<-table(Titanic$Idade,Titanic$Sobreviveu)
tabela6<-data.frame(tabela1)
ggballoonplot(tabela6, fill = "value")+
ggtitle("Sobreviventes do Titanic por Idade")
mosaicplot(tabela1, main = "Titanic- sobreviventes por classe", color = c("green","yellow"))
mosaicplot(tabela2, main = " Titanic sobreviventes por Idade", color = c("red","blue"))
vetorcor<-c("red", "blue", "green", "yellow")