library(tidyverse)
library(radiant)
library(timetk)
pokemon <- read.csv(file="D:/Users/Bichon/Documents/Data Science e Analytics/Pokemon/pokemon.csv",fileEncoding = )
pokemon <- separate(pokemon, abilities, sep = ",",
         into = c("abilities1", "abilities2"))
head(pokemon)
##    abilities1      abilities2 against_bug against_dark against_dragon
## 1 ['Overgrow'  'Chlorophyll']        1.00            1              1
## 2 ['Overgrow'  'Chlorophyll']        1.00            1              1
## 3 ['Overgrow'  'Chlorophyll']        1.00            1              1
## 4    ['Blaze'  'Solar Power']        0.50            1              1
## 5    ['Blaze'  'Solar Power']        0.50            1              1
## 6    ['Blaze'  'Solar Power']        0.25            1              1
##   against_electric against_fairy against_fight against_fire against_flying
## 1              0.5           0.5           0.5          2.0              2
## 2              0.5           0.5           0.5          2.0              2
## 3              0.5           0.5           0.5          2.0              2
## 4              1.0           0.5           1.0          0.5              1
## 5              1.0           0.5           1.0          0.5              1
## 6              2.0           0.5           0.5          0.5              1
##   against_ghost against_grass against_ground against_ice against_normal
## 1             1          0.25              1         2.0              1
## 2             1          0.25              1         2.0              1
## 3             1          0.25              1         2.0              1
## 4             1          0.50              2         0.5              1
## 5             1          0.50              2         0.5              1
## 6             1          0.25              0         1.0              1
##   against_poison against_psychic against_rock against_steel against_water
## 1              1               2            1           1.0           0.5
## 2              1               2            1           1.0           0.5
## 3              1               2            1           1.0           0.5
## 4              1               1            2           0.5           2.0
## 5              1               1            2           0.5           2.0
## 6              1               1            4           0.5           2.0
##   attack base_egg_steps base_happiness base_total capture_rate   classfication
## 1     49           5120             70        318           45   Seed Pokémon
## 2     62           5120             70        405           45   Seed Pokémon
## 3    100           5120             70        625           45   Seed Pokémon
## 4     52           5120             70        309           45 Lizard Pokémon
## 5     64           5120             70        405           45  Flame Pokémon
## 6    104           5120             70        634           45  Flame Pokémon
##   defense experience_growth height_m hp              japanese_name       name
## 1      49           1059860      0.7 45 Fushigidaneフシギãƒ\200ãƒ\215  Bulbasaur
## 2      63           1059860      1.0 60  Fushigisouフシギソウ    Ivysaur
## 3     123           1059860      2.0 80 Fushigibanaフシギãƒ\220ナ   Venusaur
## 4      43           1059860      0.6 39       Hitokageヒãƒ\210カゲ Charmander
## 5      58           1059860      1.1 58        Lizardoリザード Charmeleon
## 6      78           1059860      1.7 78    Lizardonリザードン  Charizard
##   percentage_male pokedex_number sp_attack sp_defense speed type1  type2
## 1            88.1              1        65         65    45 grass poison
## 2            88.1              2        80         80    60 grass poison
## 3            88.1              3       122        120    80 grass poison
## 4            88.1              4        60         50    65  fire       
## 5            88.1              5        80         65    80  fire       
## 6            88.1              6       159        115   100  fire flying
##   weight_kg generation is_legendary
## 1       6.9          1            0
## 2      13.0          1            0
## 3     100.0          1            0
## 4       8.5          1            0
## 5      19.0          1            0
## 6      90.5          1            0
pokemon$abilities1 <- gsub("\\[", "", pokemon$abilities1)
pokemon$abilities1 <- gsub("\\]", "", pokemon$abilities1)
pokemon$abilities1 <- gsub("\\'", "", pokemon$abilities1)
pokemon$abilities2 <- gsub("\\'", "", pokemon$abilities2)
pokemon$abilities2 <- gsub("\\]", "", pokemon$abilities2)
head(pokemon)
##   abilities1   abilities2 against_bug against_dark against_dragon
## 1   Overgrow  Chlorophyll        1.00            1              1
## 2   Overgrow  Chlorophyll        1.00            1              1
## 3   Overgrow  Chlorophyll        1.00            1              1
## 4      Blaze  Solar Power        0.50            1              1
## 5      Blaze  Solar Power        0.50            1              1
## 6      Blaze  Solar Power        0.25            1              1
##   against_electric against_fairy against_fight against_fire against_flying
## 1              0.5           0.5           0.5          2.0              2
## 2              0.5           0.5           0.5          2.0              2
## 3              0.5           0.5           0.5          2.0              2
## 4              1.0           0.5           1.0          0.5              1
## 5              1.0           0.5           1.0          0.5              1
## 6              2.0           0.5           0.5          0.5              1
##   against_ghost against_grass against_ground against_ice against_normal
## 1             1          0.25              1         2.0              1
## 2             1          0.25              1         2.0              1
## 3             1          0.25              1         2.0              1
## 4             1          0.50              2         0.5              1
## 5             1          0.50              2         0.5              1
## 6             1          0.25              0         1.0              1
##   against_poison against_psychic against_rock against_steel against_water
## 1              1               2            1           1.0           0.5
## 2              1               2            1           1.0           0.5
## 3              1               2            1           1.0           0.5
## 4              1               1            2           0.5           2.0
## 5              1               1            2           0.5           2.0
## 6              1               1            4           0.5           2.0
##   attack base_egg_steps base_happiness base_total capture_rate   classfication
## 1     49           5120             70        318           45   Seed Pokémon
## 2     62           5120             70        405           45   Seed Pokémon
## 3    100           5120             70        625           45   Seed Pokémon
## 4     52           5120             70        309           45 Lizard Pokémon
## 5     64           5120             70        405           45  Flame Pokémon
## 6    104           5120             70        634           45  Flame Pokémon
##   defense experience_growth height_m hp              japanese_name       name
## 1      49           1059860      0.7 45 Fushigidaneフシギãƒ\200ãƒ\215  Bulbasaur
## 2      63           1059860      1.0 60  Fushigisouフシギソウ    Ivysaur
## 3     123           1059860      2.0 80 Fushigibanaフシギãƒ\220ナ   Venusaur
## 4      43           1059860      0.6 39       Hitokageヒãƒ\210カゲ Charmander
## 5      58           1059860      1.1 58        Lizardoリザード Charmeleon
## 6      78           1059860      1.7 78    Lizardonリザードン  Charizard
##   percentage_male pokedex_number sp_attack sp_defense speed type1  type2
## 1            88.1              1        65         65    45 grass poison
## 2            88.1              2        80         80    60 grass poison
## 3            88.1              3       122        120    80 grass poison
## 4            88.1              4        60         50    65  fire       
## 5            88.1              5        80         65    80  fire       
## 6            88.1              6       159        115   100  fire flying
##   weight_kg generation is_legendary
## 1       6.9          1            0
## 2      13.0          1            0
## 3     100.0          1            0
## 4       8.5          1            0
## 5      19.0          1            0
## 6      90.5          1            0
pokemon$classfication <- gsub("Pokémon","",pokemon$classfication)
pokemon <- select(pokemon, -japanese_name)
pokemon <- relocate(pokemon, name, pokedex_number, hp, attack, defense, sp_attack, sp_defense, speed)
head(pokemon)
##         name pokedex_number hp attack defense sp_attack sp_defense speed
## 1  Bulbasaur              1 45     49      49        65         65    45
## 2    Ivysaur              2 60     62      63        80         80    60
## 3   Venusaur              3 80    100     123       122        120    80
## 4 Charmander              4 39     52      43        60         50    65
## 5 Charmeleon              5 58     64      58        80         65    80
## 6  Charizard              6 78    104      78       159        115   100
##   abilities1   abilities2 against_bug against_dark against_dragon
## 1   Overgrow  Chlorophyll        1.00            1              1
## 2   Overgrow  Chlorophyll        1.00            1              1
## 3   Overgrow  Chlorophyll        1.00            1              1
## 4      Blaze  Solar Power        0.50            1              1
## 5      Blaze  Solar Power        0.50            1              1
## 6      Blaze  Solar Power        0.25            1              1
##   against_electric against_fairy against_fight against_fire against_flying
## 1              0.5           0.5           0.5          2.0              2
## 2              0.5           0.5           0.5          2.0              2
## 3              0.5           0.5           0.5          2.0              2
## 4              1.0           0.5           1.0          0.5              1
## 5              1.0           0.5           1.0          0.5              1
## 6              2.0           0.5           0.5          0.5              1
##   against_ghost against_grass against_ground against_ice against_normal
## 1             1          0.25              1         2.0              1
## 2             1          0.25              1         2.0              1
## 3             1          0.25              1         2.0              1
## 4             1          0.50              2         0.5              1
## 5             1          0.50              2         0.5              1
## 6             1          0.25              0         1.0              1
##   against_poison against_psychic against_rock against_steel against_water
## 1              1               2            1           1.0           0.5
## 2              1               2            1           1.0           0.5
## 3              1               2            1           1.0           0.5
## 4              1               1            2           0.5           2.0
## 5              1               1            2           0.5           2.0
## 6              1               1            4           0.5           2.0
##   base_egg_steps base_happiness base_total capture_rate classfication
## 1           5120             70        318           45         Seed 
## 2           5120             70        405           45         Seed 
## 3           5120             70        625           45         Seed 
## 4           5120             70        309           45       Lizard 
## 5           5120             70        405           45        Flame 
## 6           5120             70        634           45        Flame 
##   experience_growth height_m percentage_male type1  type2 weight_kg generation
## 1           1059860      0.7            88.1 grass poison       6.9          1
## 2           1059860      1.0            88.1 grass poison      13.0          1
## 3           1059860      2.0            88.1 grass poison     100.0          1
## 4           1059860      0.6            88.1  fire              8.5          1
## 5           1059860      1.1            88.1  fire             19.0          1
## 6           1059860      1.7            88.1  fire flying      90.5          1
##   is_legendary
## 1            0
## 2            0
## 3            0
## 4            0
## 5            0
## 6            0
pokemon$generation <- recode(pokemon$generation, 
                             "1" = 'Kanto',
                             "2" = 'Johto',
                             "3" = 'Hoenn',
                             "4" = 'Sinnoh',
                             "5" = 'Unova',
                             "6" = 'Kalos',
                             "7" = 'Alola',
                             "8" = 'Galar')
pokemon$capture_rate <- as.numeric(pokemon$capture_rate)
head(pokemon)
##         name pokedex_number hp attack defense sp_attack sp_defense speed
## 1  Bulbasaur              1 45     49      49        65         65    45
## 2    Ivysaur              2 60     62      63        80         80    60
## 3   Venusaur              3 80    100     123       122        120    80
## 4 Charmander              4 39     52      43        60         50    65
## 5 Charmeleon              5 58     64      58        80         65    80
## 6  Charizard              6 78    104      78       159        115   100
##   abilities1   abilities2 against_bug against_dark against_dragon
## 1   Overgrow  Chlorophyll        1.00            1              1
## 2   Overgrow  Chlorophyll        1.00            1              1
## 3   Overgrow  Chlorophyll        1.00            1              1
## 4      Blaze  Solar Power        0.50            1              1
## 5      Blaze  Solar Power        0.50            1              1
## 6      Blaze  Solar Power        0.25            1              1
##   against_electric against_fairy against_fight against_fire against_flying
## 1              0.5           0.5           0.5          2.0              2
## 2              0.5           0.5           0.5          2.0              2
## 3              0.5           0.5           0.5          2.0              2
## 4              1.0           0.5           1.0          0.5              1
## 5              1.0           0.5           1.0          0.5              1
## 6              2.0           0.5           0.5          0.5              1
##   against_ghost against_grass against_ground against_ice against_normal
## 1             1          0.25              1         2.0              1
## 2             1          0.25              1         2.0              1
## 3             1          0.25              1         2.0              1
## 4             1          0.50              2         0.5              1
## 5             1          0.50              2         0.5              1
## 6             1          0.25              0         1.0              1
##   against_poison against_psychic against_rock against_steel against_water
## 1              1               2            1           1.0           0.5
## 2              1               2            1           1.0           0.5
## 3              1               2            1           1.0           0.5
## 4              1               1            2           0.5           2.0
## 5              1               1            2           0.5           2.0
## 6              1               1            4           0.5           2.0
##   base_egg_steps base_happiness base_total capture_rate classfication
## 1           5120             70        318           45         Seed 
## 2           5120             70        405           45         Seed 
## 3           5120             70        625           45         Seed 
## 4           5120             70        309           45       Lizard 
## 5           5120             70        405           45        Flame 
## 6           5120             70        634           45        Flame 
##   experience_growth height_m percentage_male type1  type2 weight_kg generation
## 1           1059860      0.7            88.1 grass poison       6.9      Kanto
## 2           1059860      1.0            88.1 grass poison      13.0      Kanto
## 3           1059860      2.0            88.1 grass poison     100.0      Kanto
## 4           1059860      0.6            88.1  fire              8.5      Kanto
## 5           1059860      1.1            88.1  fire             19.0      Kanto
## 6           1059860      1.7            88.1  fire flying      90.5      Kanto
##   is_legendary
## 1            0
## 2            0
## 3            0
## 4            0
## 5            0
## 6            0