Passo 1 - carregar a base de dados
load("C:/Users/barba/Desktop/Base_de_dados-master/df_pokemon.RData")
load("C:/Users/barba/Desktop/Base_de_dados-master/Titanic.RData")
Passo 2 - Análise dos quartis das variáveis quantitativas da base pokemon
summary(df)
## id pokemon species_id height
## Min. : 1.0 Length:718 Min. : 1.0 Min. : 1.00
## 1st Qu.:180.2 Class :character 1st Qu.:180.2 1st Qu.: 6.00
## Median :359.5 Mode :character Median :359.5 Median : 10.00
## Mean :359.5 Mean :359.5 Mean : 11.41
## 3rd Qu.:538.8 3rd Qu.:538.8 3rd Qu.: 14.00
## Max. :718.0 Max. :718.0 Max. :145.00
## weight base_experience type_1 type_2
## Min. : 1.0 Min. : 36.00 Length:718 Length:718
## 1st Qu.: 95.0 1st Qu.: 65.25 Class :character Class :character
## Median : 280.0 Median :147.00 Mode :character Mode :character
## Mean : 568.2 Mean :141.55
## 3rd Qu.: 609.5 3rd Qu.:177.00
## Max. :9500.0 Max. :608.00
## attack defense hp special_attack
## Min. : 5.00 Min. : 5.00 Min. : 1.00 Min. : 10.00
## 1st Qu.: 53.00 1st Qu.: 50.00 1st Qu.: 50.00 1st Qu.: 45.00
## Median : 73.00 Median : 65.00 Median : 65.00 Median : 65.00
## Mean : 74.85 Mean : 70.67 Mean : 68.37 Mean : 68.47
## 3rd Qu.: 95.00 3rd Qu.: 85.00 3rd Qu.: 80.00 3rd Qu.: 90.00
## Max. :165.00 Max. :230.00 Max. :255.00 Max. :154.00
## special_defense speed color_1 color_2
## Min. : 20.00 Min. : 5.00 Length:718 Length:718
## 1st Qu.: 50.00 1st Qu.: 45.00 Class :character Class :character
## Median : 65.00 Median : 65.00 Mode :character Mode :character
## Mean : 69.09 Mean : 65.72
## 3rd Qu.: 85.00 3rd Qu.: 85.00
## Max. :230.00 Max. :160.00
## color_f egg_group_1 egg_group_2 url_image
## Length:718 Length:718 Length:718 Length:718
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
## x y
## Min. :-49.152 Min. :-45.793
## 1st Qu.:-17.695 1st Qu.:-17.293
## Median : 0.705 Median : -0.628
## Mean : 0.000 Mean : 0.000
## 3rd Qu.: 15.905 3rd Qu.: 18.155
## Max. : 53.142 Max. : 46.593
Passo 3 - Inspecionar os dados
str(Titanic)
## 'data.frame': 2200 obs. of 4 variables:
## $ Classe : Factor w/ 4 levels "Tripulação","Primeira",..: 2 2 2 2 2 2 2 2 2 2 ...
## $ Idade : Factor w/ 2 levels "criança","adulto": 2 2 2 2 2 2 2 2 2 2 ...
## $ Sexo : Factor w/ 2 levels "Feminino","Masculino": 2 2 2 2 2 2 2 2 2 2 ...
## $ Sobreviveu: Factor w/ 2 levels "Não sobreviveu",..: 2 2 2 2 2 2 2 2 2 2 ...
Passo 4 - Gráfico de Pizza
pie(table(Titanic$Sobreviveu))

Passo 5 - tabelas
tabela_sexo <- table(Titanic$Sexo,Titanic$Sobreviveu)
tabela_idade <- table(Titanic$Idade, Titanic$Sobreviveu)
tabela_sexo
##
## Não sobreviveu Sobreviveu
## Feminino 126 344
## Masculino 1364 366
tabela_idade
##
## Não sobreviveu Sobreviveu
## criança 52 57
## adulto 1438 653
prop.table(tabela_sexo,1)
##
## Não sobreviveu Sobreviveu
## Feminino 0.2680851 0.7319149
## Masculino 0.7884393 0.2115607
prop.table(tabela_sexo,2)
##
## Não sobreviveu Sobreviveu
## Feminino 0.08456376 0.48450704
## Masculino 0.91543624 0.51549296
prop.table(tabela_idade,1)*100
##
## Não sobreviveu Sobreviveu
## criança 47.70642 52.29358
## adulto 68.77092 31.22908
prop.table(tabela_idade,2)*100
##
## Não sobreviveu Sobreviveu
## criança 3.489933 8.028169
## adulto 96.510067 91.971831
Passo 6 - gráfico de barras
barplot(tabela_sexo)

barplot(tabela_sexo, main = "Gráfico 1 - de sobrevivência por sexo",
col = c("yellow","purple"))

?barplot
## starting httpd help server ... done
barplot(tabela_sexo, main = "Gráfico 1 - Sobrevivência por sexo",
col = c("yellow","purple"), horiz = FALSE,beside = TRUE,
legend = rownames(tabela_sexo))

barplot(tabela_idade, main = "Gráfico 2 - Sobrevivência por idade",
col = c("yellow","blue"), horiz = FALSE,beside = TRUE, ylim = c(0,2000),
legend = rownames(tabela_idade))

verificar a tese da desigualdade da sobrevivência
tabela em números absolutos
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
tabela_classe <- Titanic %>% select(Classe,Sobreviveu) %>% table()
tabela em proporção
Titanic %>% select(Classe,Sobreviveu) %>% table() %>% prop.table(1) %>% round(2)
## Sobreviveu
## Classe Não sobreviveu Sobreviveu
## Tripulação 0.76 0.24
## Primeira 0.38 0.62
## Segunda 0.59 0.41
## Terceira 0.75 0.25
gráfico de barras em grupo
tabela_classe %>% barplot(beside=T,
col = c("#181b6e","#4c50ba","#8184e6","#3439d1"),
main = "Gráfico 3",
legend = rownames(tabela_classe),
args.legend = list(x = "topright"))
