load("C:/Users/Cliente/Desktop/Base_de_dados-master/Titanic.RData")
dim(Titanic)
## [1] 2200 4
table(Titanic$Sobreviveu)
##
## Não sobreviveu Sobreviveu
## 1490 710
round(prop.table(table(Titanic$Sobreviveu))*100,2)
##
## Não sobreviveu Sobreviveu
## 67.73 32.27
table(Titanic$Sobreviveu,Titanic$Sexo)
##
## Feminino Masculino
## Não sobreviveu 126 1364
## Sobreviveu 344 366
table(Titanic$Sobreviveu,Titanic$Idade)
##
## criança adulto
## Não sobreviveu 52 1438
## Sobreviveu 57 653
table(Titanic$Sobreviveu,Titanic$Classe)
##
## Tripulação Primeira Segunda Terceira
## Não sobreviveu 673 122 167 528
## Sobreviveu 212 202 118 178
round(prop.table(table(Titanic$Sobreviveu,Titanic$Sexo),2)*100,2)
##
## Feminino Masculino
## Não sobreviveu 26.81 78.84
## Sobreviveu 73.19 21.16
round(prop.table(table(Titanic$Sobreviveu,Titanic$Idade),2)*100,2)
##
## criança adulto
## Não sobreviveu 47.71 68.77
## Sobreviveu 52.29 31.23
round(prop.table(table(Titanic$Sobreviveu,Titanic$Classe),2)*100,2)
##
## Tripulação Primeira Segunda Terceira
## Não sobreviveu 76.05 37.65 58.60 74.79
## Sobreviveu 23.95 62.35 41.40 25.21
tabela_sobreviveu<-table(Titanic$Sobreviveu)
barplot(tabela_sobreviveu,
beside=TRUE,
col=c("red","blue"),
main = "Sobreviventes (Titanic)",
ylim = c(0,2000),ylab="Pessoas a bordo",xlab="Status Pós-Acidente",
legend.text = TRUE)
bp <- barplot(tabela_sobreviveu,
beside=TRUE,
col=c("black","green"),
main = "Percentual de Sobreviventes ao Titanic",
ylim = c(0,2000),ylab="Quantidade de Pessoas",xlab="Pós-Acidente",
legend.text = TRUE)
Titanic$Sexo<-factor(Titanic$Sexo, levels = c("Masculino","Feminino"))
tabela_sobreviveu_sexo<-table(Titanic$Sobreviveu,Titanic$Sexo)
bp <- barplot(tabela_sobreviveu_sexo,
beside=TRUE,
col=c("black","blue"),
main = "Sobreviventes ao Titanic segregados por sexo",
ylim = c(0,1400),ylab="Quantidade de Pessoas",xlab="Sexo",
legend.text = TRUE)
rotulo <- paste0(round(prop.table(tabela_sobreviveu_sexo)*100,2),"%")
text (bp, 0, rotulo, cex = 0.7, pos = 3, col = "white")
mosaicplot(table(Titanic$Classe,Titanic$Sobreviveu), main = "Sobreviventes do Titanic", color = c("black","blue"))
Titanic$Sexo<-factor(Titanic$Sexo, levels = c("Masculino","Feminino"))
tabela_classe_sexo<-table(Titanic$Classe,Titanic$Sexo)
bp2 <- barplot(tabela_classe_sexo,
beside=TRUE,
col=c("yellow","green", "skyblue", "red"),
main = "Pessoas a bordo do Titanic divididas por classe e sexo",
ylim = c(0,1000),ylab="Pessoas a bordo",xlab="Sexo",
legend.text = TRUE)
rotulo2 <- paste0(round(prop.table(tabela_classe_sexo)*100,2),"%")
text (bp2, 0, rotulo2, cex = 0.7, pos = 3, col = "black")
table(Titanic$Classe,Titanic$Sexo)
##
## Masculino Feminino
## Tripulação 862 23
## Primeira 179 145
## Segunda 179 106
## Terceira 510 196
table(Titanic$Classe,Titanic$Sobreviveu)
##
## Não sobreviveu Sobreviveu
## Tripulação 673 212
## Primeira 122 202
## Segunda 167 118
## Terceira 528 178
#Dawson, Robert J. MacG. “The “unusual episode” data revisited." Journal of Statistics Education 3.3 (1995). #Simonoff, Jeffrey S. “The “Unusual Episode” and a second statistics course." Journal of Statistics Education 5.1 (1997)