library (readr)
Pokemon <- read_csv ("Pokemon.csv" )
Rows: 800 Columns: 13
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): Name, Type 1, Type 2
dbl (9): #, Total, HP, Attack, Defense, Sp. Atk, Sp. Def, Speed, Generation
lgl (1): Legendary
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
spc_tbl_ [800 × 13] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
$ # : num [1:800] 1 2 3 3 4 5 6 6 6 7 ...
$ Name : chr [1:800] "Bulbasaur" "Ivysaur" "Venusaur" "VenusaurMega Venusaur" ...
$ Type 1 : chr [1:800] "Grass" "Grass" "Grass" "Grass" ...
$ Type 2 : chr [1:800] "Poison" "Poison" "Poison" "Poison" ...
$ Total : num [1:800] 318 405 525 625 309 405 534 634 634 314 ...
$ HP : num [1:800] 45 60 80 80 39 58 78 78 78 44 ...
$ Attack : num [1:800] 49 62 82 100 52 64 84 130 104 48 ...
$ Defense : num [1:800] 49 63 83 123 43 58 78 111 78 65 ...
$ Sp. Atk : num [1:800] 65 80 100 122 60 80 109 130 159 50 ...
$ Sp. Def : num [1:800] 65 80 100 120 50 65 85 85 115 64 ...
$ Speed : num [1:800] 45 60 80 80 65 80 100 100 100 43 ...
$ Generation: num [1:800] 1 1 1 1 1 1 1 1 1 1 ...
$ Legendary : logi [1:800] FALSE FALSE FALSE FALSE FALSE FALSE ...
- attr(*, "spec")=
.. cols(
.. `#` = col_double(),
.. Name = col_character(),
.. `Type 1` = col_character(),
.. `Type 2` = col_character(),
.. Total = col_double(),
.. HP = col_double(),
.. Attack = col_double(),
.. Defense = col_double(),
.. `Sp. Atk` = col_double(),
.. `Sp. Def` = col_double(),
.. Speed = col_double(),
.. Generation = col_double(),
.. Legendary = col_logical()
.. )
- attr(*, "problems")=<externalptr>
Pokemon$ Name <- NULL
Pokemon$ ` # ` <- NULL
Pokemon$ ` Type 1 ` <- as.factor (Pokemon$ ` Type 1 ` )
Pokemon$ ` Type 2 ` <- as.factor (Pokemon$ ` Type 2 ` )
Pokemon$ Generation <- as.factor (Pokemon$ Generation)
Pokemon$ Legendary <- as.factor (Pokemon$ Legendary)
spc_tbl_ [800 × 11] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
$ Type 1 : Factor w/ 18 levels "Bug","Dark","Dragon",..: 10 10 10 10 7 7 7 7 7 18 ...
$ Type 2 : Factor w/ 18 levels "Bug","Dark","Dragon",..: 14 14 14 14 NA NA 8 3 8 NA ...
$ Total : num [1:800] 318 405 525 625 309 405 534 634 634 314 ...
$ HP : num [1:800] 45 60 80 80 39 58 78 78 78 44 ...
$ Attack : num [1:800] 49 62 82 100 52 64 84 130 104 48 ...
$ Defense : num [1:800] 49 63 83 123 43 58 78 111 78 65 ...
$ Sp. Atk : num [1:800] 65 80 100 122 60 80 109 130 159 50 ...
$ Sp. Def : num [1:800] 65 80 100 120 50 65 85 85 115 64 ...
$ Speed : num [1:800] 45 60 80 80 65 80 100 100 100 43 ...
$ Generation: Factor w/ 6 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
$ Legendary : Factor w/ 2 levels "FALSE","TRUE": 1 1 1 1 1 1 1 1 1 1 ...
- attr(*, "spec")=
.. cols(
.. `#` = col_double(),
.. Name = col_character(),
.. `Type 1` = col_character(),
.. `Type 2` = col_character(),
.. Total = col_double(),
.. HP = col_double(),
.. Attack = col_double(),
.. Defense = col_double(),
.. `Sp. Atk` = col_double(),
.. `Sp. Def` = col_double(),
.. Speed = col_double(),
.. Generation = col_double(),
.. Legendary = col_logical()
.. )
- attr(*, "problems")=<externalptr>
[1] "Bug" "Dark" "Dragon" "Electric" "Fairy" "Fighting"
[7] "Fire" "Flying" "Ghost" "Grass" "Ground" "Ice"
[13] "Normal" "Poison" "Psychic" "Rock" "Steel" "Water"
levels (Pokemon$ ` Type 1 ` ) <- c ("Inseto" , "Sombrio" , "Dragão" , "Elétrico" , "Fada" , "Lutador" , "Fogo" , "Voador" , "Fantasma" , "Planta" , "Terrestre" , "Gelo" , "Normal" , "Venenoso" , "Psíquico" , "Pedra" , "Aço" , "Água" )
levels (Pokemon$ ` Type 2 ` )
[1] "Bug" "Dark" "Dragon" "Electric" "Fairy" "Fighting"
[7] "Fire" "Flying" "Ghost" "Grass" "Ground" "Ice"
[13] "Normal" "Poison" "Psychic" "Rock" "Steel" "Water"
levels (Pokemon$ ` Type 2 ` ) <- c ("Inseto" , "Sombrio" , "Dragão" , "Elétrico" , "Fada" , "Lutador" , "Fogo" , "Voador" , "Fantasma" , "Planta" , "Terrestre" , "Gelo" , "Normal" , "Venenoso" , "Psíquico" , "Pedra" , "Aço" , "Água" )
levels (Pokemon$ Legendary)
levels (Pokemon$ Legendary) <- c ("Não" , "Sim" )
[1] "Type 1" "Type 2" "Total" "HP" "Attack"
[6] "Defense" "Sp. Atk" "Sp. Def" "Speed" "Generation"
[11] "Legendary"
colnames (Pokemon) [1 ] <- "Tipo_1"
colnames (Pokemon) [2 ] <- "Tipo_2"
colnames (Pokemon) [3 ] <- "Status Base"
colnames (Pokemon) [4 ] <- "Vida"
colnames (Pokemon) [5 ] <- "Ataque"
colnames (Pokemon) [6 ] <- "Defesa"
colnames (Pokemon) [7 ] <- "Ataque especial"
colnames (Pokemon) [8 ] <- "Defesa especial"
colnames (Pokemon) [9 ] <- "Velocidade"
colnames (Pokemon) [10 ] <- "Geração"
colnames (Pokemon) [11 ] <- "Lendário"
library (summarytools)
freq (Pokemon$ ` Tipo_1 ` )
Frequencies
Pokemon$Tipo_1
Type: Factor
Freq % Valid % Valid Cum. % Total % Total Cum.
--------------- ------ --------- -------------- --------- --------------
Inseto 69 8.62 8.62 8.62 8.62
Sombrio 31 3.88 12.50 3.88 12.50
Dragão 32 4.00 16.50 4.00 16.50
Elétrico 44 5.50 22.00 5.50 22.00
Fada 17 2.12 24.12 2.12 24.12
Lutador 27 3.38 27.50 3.38 27.50
Fogo 52 6.50 34.00 6.50 34.00
Voador 4 0.50 34.50 0.50 34.50
Fantasma 32 4.00 38.50 4.00 38.50
Planta 70 8.75 47.25 8.75 47.25
Terrestre 32 4.00 51.25 4.00 51.25
Gelo 24 3.00 54.25 3.00 54.25
Normal 98 12.25 66.50 12.25 66.50
Venenoso 28 3.50 70.00 3.50 70.00
Psíquico 57 7.12 77.12 7.12 77.12
Pedra 44 5.50 82.62 5.50 82.62
Aço 27 3.38 86.00 3.38 86.00
Água 112 14.00 100.00 14.00 100.00
<NA> 0 0.00 100.00
Total 800 100.00 100.00 100.00 100.00
Frequencies
Pokemon$Tipo_2
Type: Factor
Freq % Valid % Valid Cum. % Total % Total Cum.
--------------- ------ --------- -------------- --------- --------------
Inseto 3 0.72 0.72 0.38 0.38
Sombrio 20 4.83 5.56 2.50 2.88
Dragão 18 4.35 9.90 2.25 5.12
Elétrico 6 1.45 11.35 0.75 5.88
Fada 23 5.56 16.91 2.88 8.75
Lutador 26 6.28 23.19 3.25 12.00
Fogo 12 2.90 26.09 1.50 13.50
Voador 97 23.43 49.52 12.12 25.62
Fantasma 14 3.38 52.90 1.75 27.38
Planta 25 6.04 58.94 3.12 30.50
Terrestre 35 8.45 67.39 4.38 34.88
Gelo 14 3.38 70.77 1.75 36.62
Normal 4 0.97 71.74 0.50 37.12
Venenoso 34 8.21 79.95 4.25 41.38
Psíquico 33 7.97 87.92 4.12 45.50
Pedra 14 3.38 91.30 1.75 47.25
Aço 22 5.31 96.62 2.75 50.00
Água 14 3.38 100.00 1.75 51.75
<NA> 386 48.25 100.00
Total 800 100.00 100.00 100.00 100.00
library (gtsummary)
Pokemon2 <- Pokemon[, c ("Tipo_1" , "Tipo_2" ,
"Status Base" ,
"Vida" ,
"Ataque" ,
"Defesa" , "Ataque especial" , "Defesa especial" , "Velocidade" ,
"Geração" , "Lendário" )]
tbl_summary (Pokemon2, label = list (Tipo_1 ~ "Tipo 1" ,
Tipo_2 ~ "Tipo 2" ),
missing_text = "Sem informação" ) %>%
modify_header (label ~ "**Variáveis**" ) %>%
modify_caption ("Tabela 1. Características dos pokémons." ) %>% bold_labels () %>% italicize_levels ()
Tabela 1. Características dos pokémons.
Variáveis
N = 800
Tipo 1
Inseto
69 (8.6%)
Sombrio
31 (3.9%)
Dragão
32 (4.0%)
Elétrico
44 (5.5%)
Fada
17 (2.1%)
Lutador
27 (3.4%)
Fogo
52 (6.5%)
Voador
4 (0.5%)
Fantasma
32 (4.0%)
Planta
70 (8.8%)
Terrestre
32 (4.0%)
Gelo
24 (3.0%)
Normal
98 (12%)
Venenoso
28 (3.5%)
Psíquico
57 (7.1%)
Pedra
44 (5.5%)
Aço
27 (3.4%)
Água
112 (14%)
Tipo 2
Inseto
3 (0.7%)
Sombrio
20 (4.8%)
Dragão
18 (4.3%)
Elétrico
6 (1.4%)
Fada
23 (5.6%)
Lutador
26 (6.3%)
Fogo
12 (2.9%)
Voador
97 (23%)
Fantasma
14 (3.4%)
Planta
25 (6.0%)
Terrestre
35 (8.5%)
Gelo
14 (3.4%)
Normal
4 (1.0%)
Venenoso
34 (8.2%)
Psíquico
33 (8.0%)
Pedra
14 (3.4%)
Aço
22 (5.3%)
Água
14 (3.4%)
Sem informação
386
Status Base
450 (330, 515)
Vida
65 (50, 80)
Ataque
75 (55, 100)
Defesa
70 (50, 90)
Ataque especial
65 (50, 95)
Defesa especial
70 (50, 90)
Velocidade
65 (45, 90)
Geração
1
166 (21%)
2
106 (13%)
3
160 (20%)
4
121 (15%)
5
165 (21%)
6
82 (10%)
Lendário
Não
735 (92%)
Sim
65 (8.1%)
Tabela 3. Correlacionando as variáveis quantitativas “Vida” e “Defesa”
library (ggplot2)
ggplot (Pokemon2) +
aes (x = Vida, y = Defesa) +
geom_point (shape = "circle" , size = 0.9 , colour = "#000000" ) +
labs (title = "Correlação entre a vida e a defesa dos Pokémons" ) +
theme_bw () +
theme (plot.title = element_text (size = 18L,
face = "bold" , hjust = 0.5 ), axis.title.y = element_text (size = 15L, face = "bold" ), axis.title.x = element_text (size = 15L,
face = "bold" ))
A partir da análise do gráfico acima, é possível concluir que não há correlação entre a vida e a defesa dos pokémons.Ambas as variáves podem apresentar valores altos ou baixos independentemente de uma relação proporcional entre si.