R Markdown

O presente relatório tem por objetivo fazer um resumo (média, mediana, desvio-padrão, etc) de uma variável quantitativa por grupos de uma variável qualitativa de personagens do jogo Pokemon.

#A base de dados utilizada se chama “df-pokemon.Rdata”

#————————— #Carregando as Bibliotecas# #—————————

library(readxl)
library(flextable)
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
library(janitor)
## 
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
library(RColorBrewer)
Carregando a base de dados e mostrando as primeiras linhas
load("C:/Users/wandr/OneDrive/Documentos/ENEM_UNIRIO/2022.2/R/Base_de_dados-master/df_pokemon.RData")
df %>% head() %>% data.frame() %>% flextable()

A variável qualitativa estudada é o tipo de personagem 1 (type_1)

Personagens_Tipo1 = table(df$type_1)
Personagens_Tipo1
## 
##      bug     dark   dragon electric    fairy fighting     fire   flying 
##       63       28       24       36       17       25       46        3 
##    ghost    grass   ground      ice   normal   poison  psychic     rock 
##       23       66       30       23       93       28       46       40 
##    steel    water 
##       22      105
aaa = df %>% tabyl(type_1) 
aaa$percent=aaa$percent*100

aaa%>% flextable()%>% set_header_labels(type_1="Tipo",n="Contagem",percent="%") %>% theme_tron_legacy()

#-

A variável quantitativa estudada é a altura do ovo do personagem (height)

summary(df$height)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1.00    6.00   10.00   11.41   14.00  145.00

Interpetração: A maior concentração de eventos se encontra no 3° quartil.

Relacionando as 2 variáveis

df %>% select(type_1,height) %>%
  group_by(type_1) %>%
  summarise(Média_Altura=mean(height), Mediana_Altura=median(height), Desvio_Padrao_Altura=sd(height), Mínimo_Altura=min(height),
            Máximo_Altura=max(height)) %>% flextable()%>% set_header_labels(type_1="Tipo") %>% theme_tron_legacy()

Gerando o gráfico boxplot

par(cex=0.5)
boxplot(df$height ~ df$type_1,
        xlab = "Tipo de Pokemon",
        ylab = "Altura do ovo",
        col = c("#de9f16"))

Interpretação:

1- Todos os tipos têm outliers, exceto os tipos “eletric” e “flying”. O tipo “water” é o que possui mais outliers.

2- Todos os tipos são assimétricos.

3- O menor desvio padrão, e consequentemente a menor dispersão, encontra-se no tipo “fighting”.

4- O maior desvio padrão, e consequentemente a maior dispersão, encontra-se no tipo “steel”.