#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)
load("C:/Users/wandr/OneDrive/Documentos/ENEM_UNIRIO/2022.2/R/Base_de_dados-master/df_pokemon.RData")
df %>% head() %>% data.frame() %>% flextable()
id | pokemon | species_id | height | weight | base_experience | type_1 | type_2 | attack | defense | hp | special_attack | special_defense | speed | color_1 | color_2 | color_f | egg_group_1 | egg_group_2 | url_image | x | y |
1 | bulbasaur | 1 | 7 | 69 | 64 | grass | poison | 49 | 49 | 45 | 65 | 65 | 45 | #78C850 | #A040A0 | #81A763 | monster | plant | 1.png | 32.82239 | 17.21614 |
2 | ivysaur | 2 | 10 | 130 | 142 | grass | poison | 62 | 63 | 60 | 80 | 80 | 60 | #78C850 | #A040A0 | #81A763 | monster | plant | 2.png | 33.32643 | 16.71226 |
3 | venusaur | 3 | 20 | 1,000 | 236 | grass | poison | 82 | 83 | 80 | 100 | 100 | 80 | #78C850 | #A040A0 | #81A763 | monster | plant | 3.png | 33.93778 | 16.17232 |
4 | charmander | 4 | 6 | 85 | 62 | fire | 52 | 43 | 39 | 60 | 50 | 65 | #F08030 | #F08030 | monster | dragon | 4.png | -24.36338 | 30.78973 | ||
5 | charmeleon | 5 | 11 | 190 | 142 | fire | 64 | 58 | 58 | 80 | 65 | 80 | #F08030 | #F08030 | monster | dragon | 5.png | -24.57820 | 30.60161 | ||
6 | charizard | 6 | 17 | 905 | 240 | fire | flying | 84 | 78 | 78 | 109 | 85 | 100 | #F08030 | #A890F0 | #DE835E | monster | dragon | 6.png | -25.50657 | 29.77037 |
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()
Tipo | Contagem | % |
bug | 63 | 8.7743733 |
dark | 28 | 3.8997214 |
dragon | 24 | 3.3426184 |
electric | 36 | 5.0139276 |
fairy | 17 | 2.3676880 |
fighting | 25 | 3.4818942 |
fire | 46 | 6.4066852 |
flying | 3 | 0.4178273 |
ghost | 23 | 3.2033426 |
grass | 66 | 9.1922006 |
ground | 30 | 4.1782730 |
ice | 23 | 3.2033426 |
normal | 93 | 12.9526462 |
poison | 28 | 3.8997214 |
psychic | 46 | 6.4066852 |
rock | 40 | 5.5710306 |
steel | 22 | 3.0640669 |
water | 105 | 14.6239554 |
#-
summary(df$height)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.00 6.00 10.00 11.41 14.00 145.00
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()
Tipo | Média_Altura | Mediana_Altura | Desvio_Padrao_Altura | Mínimo_Altura | Máximo_Altura |
bug | 8.603175 | 8.0 | 4.927015 | 1 | 25 |
dark | 11.464286 | 10.0 | 10.031366 | 4 | 58 |
dragon | 20.375000 | 17.0 | 15.468938 | 3 | 70 |
electric | 8.944444 | 8.0 | 5.312758 | 2 | 21 |
fairy | 8.352941 | 6.0 | 7.088205 | 1 | 30 |
fighting | 11.680000 | 12.0 | 4.616276 | 5 | 23 |
fire | 11.500000 | 10.0 | 6.344727 | 4 | 38 |
flying | 11.666667 | 15.0 | 5.773503 | 5 | 15 |
ghost | 11.608696 | 10.0 | 8.850984 | 3 | 45 |
grass | 9.833333 | 9.0 | 6.200703 | 2 | 33 |
ground | 12.066667 | 10.0 | 7.745670 | 2 | 35 |
ice | 12.086957 | 11.0 | 6.119366 | 4 | 26 |
normal | 9.795699 | 9.0 | 6.168925 | 2 | 37 |
poison | 12.142857 | 11.0 | 7.311656 | 4 | 35 |
psychic | 9.565217 | 7.5 | 8.023998 | 2 | 52 |
rock | 13.400000 | 12.0 | 13.371995 | 3 | 88 |
steel | 15.818182 | 8.5 | 20.332091 | 2 | 92 |
water | 13.209524 | 10.0 | 16.360538 | 3 | 145 |
par(cex=0.5)
boxplot(df$height ~ df$type_1,
xlab = "Tipo de Pokemon",
ylab = "Altura do ovo",
col = c("#de9f16"))