Passo 1 - Carregar os dados

load("C:/Users/Rica Meira/Desktop/Base_de_dados-master/df_pokemon.RData")
load("C:/Users/Rica Meira/Desktop/Base_de_dados-master/Titanic.RData")

Passo 2 - Análise dos quartis das variáveis quantitativas da base pokémon

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)*100
##            
##             Não sobreviveu Sobreviveu
##   Feminino        26.80851   73.19149
##   Masculino       78.84393   21.15607
prop.table(tabela_sexo,2)*100
##            
##             Não sobreviveu Sobreviveu
##   Feminino        8.456376  48.450704
##   Masculino      91.543624  51.549296
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,main = "Gráfico 1 - Sobrevivência por sexo",
        col = c("goldenrod","navyblue"),horiz = FALSE,beside = TRUE,
        legend = rownames(tabela_sexo))

barplot(tabela_idade,main = "Gráfico 2 - Sobrevivência por idade",
        col = c("tomato4","wheat"),horiz = FALSE,beside = TRUE,
        legend = rownames(tabela_idade))

Passo 7 - Verificar a hipótese das classes

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 em números absolutos
tabela_classe <- Titanic %>% select(Classe,Sobreviveu) %>% table()
tabela_classe
##             Sobreviveu
## Classe       Não sobreviveu Sobreviveu
##   Tripulação            673        212
##   Primeira              122        202
##   Segunda               167        118
##   Terceira              528        178
#tabela em proporção
tabela_classe_prop <- Titanic %>% select(Classe,Sobreviveu) %>% table() %>%
  prop.table(1) %>% round(2)*100
tabela_classe_prop
##             Sobreviveu
## Classe       Não sobreviveu Sobreviveu
##   Tripulação             76         24
##   Primeira               38         62
##   Segunda                59         41
##   Terceira               75         25
#gráfico de barras
tabela_classe %>% barplot(beside=T,
                          col=c("blue","red","yellow","green"),
                          main= "Gráfico 3 - Sobrevivência por classes",
                          legend = rownames(tabela_classe),
                          ylim=c(0,800))