Introdução

Este trabalho terá como base um banco de dados chamado “df” e, a partir dele, irei analisar duas variáveis: uma qualitativa e uma quantitativa, apresentando um resumo com a média, mediana, desvio-padrão e um boxplot.

Carregar as bibliotecas

library(readxl)
library(flextable)
library(dplyr)
library(ggplot2)

Importar a base de dados

load("C:/Users/19801926775/Desktop/Base_de_dados-master/df_pokemon.RData")

Resumo da base de dados

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

Classificando as variáveis

class(df$id)
## [1] "numeric"
class(df$pokemon)
## [1] "character"
class(df$species_id)
## [1] "integer"
class(df$height)
## [1] "integer"
class(df$weight)
## [1] "integer"
class(df$base_experience)
## [1] "integer"
class(df$type_1)
## [1] "character"
class(df$type_2)
## [1] "character"
class(df$attack)
## [1] "integer"
class(df$defense)
## [1] "integer"
class(df$hp)
## [1] "integer"
class(df$special_attack)
## [1] "integer"
class(df$special_defense)
## [1] "integer"
class(df$speed)
## [1] "integer"
class(df$color_1)
## [1] "character"
class(df$color_2)
## [1] "character"
class(df$color_f)
## [1] "character"
class(df$egg_group_1)
## [1] "character"
class(df$egg_group_2)
## [1] "character"
class(df$url_image)
## [1] "character"
class(df$x)
## [1] "numeric"
class(df$y)
## [1] "numeric"

Mostrar a base de dados

head(df) %>% flextable() %>% theme_vader()

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

Escolhi usar a variável quantitativa “special_attack” e a variável qualitativa “type_1” pra redigir este trabalho.

Média, mediana e desvio padrão

Calculando a média

df %>% select(type_1,special_attack) %>% group_by(type_1) %>% 
  summarise(média=mean(special_attack),
            desvio_padrao=sd(special_attack)) %>% flextable()

type_1

média

desvio_padrao

bug

54.03175

27.31475

dark

70.50000

31.37645

dragon

82.45833

36.40948

electric

83.08333

26.46332

fairy

78.52941

28.54846

fighting

48.56000

22.19812

fire

82.45652

25.11282

flying

89.00000

40.59557

ghost

80.43478

28.33858

grass

74.33333

24.57099

ground

51.73333

20.97935

ice

75.69565

25.58308

normal

54.45161

22.87134

poison

60.42857

19.32266

psychic

89.30435

29.89528

rock

59.05000

23.66752

steel

63.54545

28.28886

water

71.71429

25.98066

Mínimo, 1 quartil, Mediana, 3 quartil e Máximo

df %>% select(type_1,special_attack) %>% group_by(type_1) %>% 
  summarise(mínimo=min(special_attack),
            quartil1 = quantile(special_attack,0.25),
            mediana= median(special_attack),
            quartil3= quantile(special_attack,0.75),
            máximo=max(special_attack)) %>% 
  flextable()

type_1

mínimo

quartil1

mediana

quartil3

máximo

bug

10

32.50

50.0

67.50

135

dark

30

45.00

62.5

85.75

135

dragon

30

53.75

75.0

110.00

150

electric

35

64.00

80.5

105.00

130

fairy

40

60.00

75.0

99.00

131

fighting

20

35.00

40.0

60.00

115

fire

15

66.25

80.0

103.00

130

flying

45

71.00

97.0

111.00

125

ghost

30

60.00

83.0

97.50

145

grass

24

55.25

74.5

91.50

125

ground

20

38.50

45.0

58.75

115

ice

30

60.00

75.0

95.00

130

normal

15

40.00

50.0

65.00

135

poison

30

40.75

60.0

71.50

100

psychic

23

70.00

90.0

105.00

154

rock

10

45.00

55.0

70.50

115

steel

24

45.00

55.0

78.00

150

water

10

53.00

70.0

90.00

150

Boxplot

boxplot(df$special_attack ~ df$type_1,
        col=c("#755f5f","#bd9f9f","#dea2a2","#e3b8a3","#e3d0a3","#dde3a3","#c4e3a3","#a3e3ad","#a3e3d5","#a3d5e3","#a3bbe3","#a6a3e3","#c5a3e3","#e1a3e3","#e3a3c4","#ff9191","#b52626","#801414"),
        main="Boxplot Tipo 1 vs Ataque Especial",
        ylab = "Ataque Especial",
        xlab = "Tipo 1")

Conclusão

Neste trabalho, baseei minha análise em descobrir qual tipo de Pokemon tem um maior ataque especial. A partir da pesquisa da média, constatei que os tipos que possuem maior poder de ataque especial são o psychic e o flying, o primeiro ganhando com uma diferença bem pequena. Já ao analisar os tipos com menor poder de ataque especial, percebi que trata-se do tipo ground. O desvio padrão apresenta valores muito semelhantes entre os tipos, destacando-se o tipo flying, que apresenta o maior desvio padrão da tabela, e o tipo poison, que apresenta o menor desvio padrão.

A maior mediana é apresentada pelo tipo flying e a menor é do tipo fighting.

Portanto, concluí que o tipo psychic é o que possui maior poder de ataque especial e os tipos que possuem menor poder de ataque especial são fighting, ground e rock.