library(tidyr)
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(stringr)
library(ggplot2)
# Get data from file I uploaded to github
theURL <- "https://raw.githubusercontent.com/bpersaud104/Data607/master/Pokemon(csv).csv"
Pokemon <- read.table(file = theURL, header = TRUE, sep = ",")
head(Pokemon)
## Number Name Type1 Type2 Total HP Attack Defense
## 1 1 Bulbasaur Grass Poison 318 45 49 49
## 2 2 Ivysaur Grass Poison 405 60 62 63
## 3 3 Venusaur Grass Poison 525 80 82 83
## 4 3 VenusaurMega Venusaur Grass Poison 625 80 100 123
## 5 4 Charmander Fire <NA> 309 39 52 43
## 6 5 Charmeleon Fire <NA> 405 58 64 58
## SpecialAtk SpecialDef Speed Generation Legendary
## 1 65 65 45 1 FALSE
## 2 80 80 60 1 FALSE
## 3 100 100 80 1 FALSE
## 4 122 120 80 1 FALSE
## 5 60 50 65 1 FALSE
## 6 80 65 80 1 FALSE
Pokedex <- select(Pokemon, Number, Name, Type1, Type2, Generation, Legendary)
head(Pokedex)
## Number Name Type1 Type2 Generation Legendary
## 1 1 Bulbasaur Grass Poison 1 FALSE
## 2 2 Ivysaur Grass Poison 1 FALSE
## 3 3 Venusaur Grass Poison 1 FALSE
## 4 3 VenusaurMega Venusaur Grass Poison 1 FALSE
## 5 4 Charmander Fire <NA> 1 FALSE
## 6 5 Charmeleon Fire <NA> 1 FALSE
Statistics <- select(Pokemon, Number, Name, HP, Attack, Defense, SpecialAtk, SpecialDef, Speed, Total)
head(Statistics)
## Number Name HP Attack Defense SpecialAtk SpecialDef
## 1 1 Bulbasaur 45 49 49 65 65
## 2 2 Ivysaur 60 62 63 80 80
## 3 3 Venusaur 80 82 83 100 100
## 4 3 VenusaurMega Venusaur 80 100 123 122 120
## 5 4 Charmander 39 52 43 60 50
## 6 5 Charmeleon 58 64 58 80 65
## Speed Total
## 1 45 318
## 2 60 405
## 3 80 525
## 4 80 625
## 5 65 309
## 6 80 405
The only tidying needed to be done was to seperate the data into two tables. One table showing the pokemon’s information, i.e their type(s), what generation they’re from, and if they are legendary or not. The other table shows the pokemon’s stats, ranging from six different attributes, hp, attack, defense, special attack, special defense, and speed. The total of all these attributes for each pokemon is also listed.
The analysis we want to see is comparing the strongest and weakest pokemon between two different types. Let’s compare the strongest and weakest pokemon for electric and grass type pokemon. Since there are some pokemon that have two types, lets include any pokemon as long as their type is either electric or grass. Even though we did some data tidying, we can actually use the original dataset to do this kind of analysis.
# List all electric type pokemon
Electric_pokemon <- filter(Pokemon, Type1 == 'Electric' | Type2 == 'Electric')
Electric_pokemon
## Number Name Type1 Type2 Total HP Attack
## 1 25 Pikachu Electric <NA> 320 35 55
## 2 26 Raichu Electric <NA> 485 60 90
## 3 81 Magnemite Electric Steel 325 25 35
## 4 82 Magneton Electric Steel 465 50 60
## 5 100 Voltorb Electric <NA> 330 40 30
## 6 101 Electrode Electric <NA> 480 60 50
## 7 125 Electabuzz Electric <NA> 490 65 83
## 8 135 Jolteon Electric <NA> 525 65 65
## 9 145 Zapdos Electric Flying 580 90 90
## 10 170 Chinchou Water Electric 330 75 38
## 11 171 Lanturn Water Electric 460 125 58
## 12 172 Pichu Electric <NA> 205 20 40
## 13 179 Mareep Electric <NA> 280 55 40
## 14 180 Flaaffy Electric <NA> 365 70 55
## 15 181 Ampharos Electric <NA> 510 90 75
## 16 181 AmpharosMega Ampharos Electric Dragon 610 90 95
## 17 239 Elekid Electric <NA> 360 45 63
## 18 243 Raikou Electric <NA> 580 90 85
## 19 309 Electrike Electric <NA> 295 40 45
## 20 310 Manectric Electric <NA> 475 70 75
## 21 310 ManectricMega Manectric Electric <NA> 575 70 75
## 22 311 Plusle Electric <NA> 405 60 50
## 23 312 Minun Electric <NA> 405 60 40
## 24 403 Shinx Electric <NA> 263 45 65
## 25 404 Luxio Electric <NA> 363 60 85
## 26 405 Luxray Electric <NA> 523 80 120
## 27 417 Pachirisu Electric <NA> 405 60 45
## 28 462 Magnezone Electric Steel 535 70 70
## 29 466 Electivire Electric <NA> 540 75 123
## 30 479 Rotom Electric Ghost 440 50 50
## 31 479 RotomHeat Rotom Electric Fire 520 50 65
## 32 479 RotomWash Rotom Electric Water 520 50 65
## 33 479 RotomFrost Rotom Electric Ice 520 50 65
## 34 479 RotomFan Rotom Electric Flying 520 50 65
## 35 479 RotomMow Rotom Electric Grass 520 50 65
## 36 522 Blitzle Electric <NA> 295 45 60
## 37 523 Zebstrika Electric <NA> 497 75 100
## 38 587 Emolga Electric Flying 428 55 75
## 39 595 Joltik Bug Electric 319 50 47
## 40 596 Galvantula Bug Electric 472 70 77
## 41 602 Tynamo Electric <NA> 275 35 55
## 42 603 Eelektrik Electric <NA> 405 65 85
## 43 604 Eelektross Electric <NA> 515 85 115
## 44 618 Stunfisk Ground Electric 471 109 66
## 45 642 ThundurusIncarnate Forme Electric Flying 580 79 115
## 46 642 ThundurusTherian Forme Electric Flying 580 79 105
## 47 644 Zekrom Dragon Electric 680 100 150
## 48 694 Helioptile Electric Normal 289 44 38
## 49 695 Heliolisk Electric Normal 481 62 55
## 50 702 Dedenne Electric Fairy 431 67 58
## 51 737 Charjabug Bug Electric 400 57 82
## 52 738 Vikavolt Bug Electric 500 77 70
## 53 741 OricorioPom-Pom Style Electric Flying 476 75 70
## 54 777 Togedemaru Electric Steel 435 65 98
## 55 785 Tapu Koko Electric Fairy 570 70 115
## 56 796 Xuriktree Electric <NA> 570 83 89
## 57 807 Zenaora Electric <NA> 600 88 112
## Defense SpecialAtk SpecialDef Speed Generation Legendary
## 1 40 50 50 90 1 FALSE
## 2 55 90 80 110 1 FALSE
## 3 70 95 55 45 1 FALSE
## 4 95 120 70 70 1 FALSE
## 5 50 55 55 100 1 FALSE
## 6 70 80 80 140 1 FALSE
## 7 57 95 85 105 1 FALSE
## 8 60 110 95 130 1 FALSE
## 9 85 125 90 100 1 TRUE
## 10 38 56 56 67 2 FALSE
## 11 58 76 76 67 2 FALSE
## 12 15 35 35 60 2 FALSE
## 13 40 65 45 35 2 FALSE
## 14 55 80 60 45 2 FALSE
## 15 85 115 90 55 2 FALSE
## 16 105 165 110 45 2 FALSE
## 17 37 65 55 95 2 FALSE
## 18 75 115 100 115 2 TRUE
## 19 40 65 40 65 3 FALSE
## 20 60 105 60 105 3 FALSE
## 21 80 135 80 135 3 FALSE
## 22 40 85 75 95 3 FALSE
## 23 50 75 85 95 3 FALSE
## 24 34 40 34 45 4 FALSE
## 25 49 60 49 60 4 FALSE
## 26 79 95 79 70 4 FALSE
## 27 70 45 90 95 4 FALSE
## 28 115 130 90 60 4 FALSE
## 29 67 95 85 95 4 FALSE
## 30 77 95 77 91 4 FALSE
## 31 107 105 107 86 4 FALSE
## 32 107 105 107 86 4 FALSE
## 33 107 105 107 86 4 FALSE
## 34 107 105 107 86 4 FALSE
## 35 107 105 107 86 4 FALSE
## 36 32 50 32 76 5 FALSE
## 37 63 80 63 116 5 FALSE
## 38 60 75 60 103 5 FALSE
## 39 50 57 50 65 5 FALSE
## 40 60 97 60 108 5 FALSE
## 41 40 45 40 60 5 FALSE
## 42 70 75 70 40 5 FALSE
## 43 80 105 80 50 5 FALSE
## 44 84 81 99 32 5 FALSE
## 45 70 125 80 111 5 TRUE
## 46 70 145 80 101 5 TRUE
## 47 120 120 100 90 5 TRUE
## 48 33 61 43 70 6 FALSE
## 49 52 109 94 109 6 FALSE
## 50 57 81 67 101 6 FALSE
## 51 95 55 75 36 7 FALSE
## 52 90 145 75 43 7 FALSE
## 53 70 98 70 93 7 FALSE
## 54 63 40 73 96 7 FALSE
## 55 85 95 75 130 7 TRUE
## 56 71 173 71 83 7 FALSE
## 57 75 102 80 143 7 FALSE
# List all grass type pokemon
Grass_pokemon <- filter(Pokemon, Type1 == 'Grass' | Type2 == 'Grass')
Grass_pokemon
## Number Name Type1 Type2 Total HP Attack
## 1 1 Bulbasaur Grass Poison 318 45 49
## 2 2 Ivysaur Grass Poison 405 60 62
## 3 3 Venusaur Grass Poison 525 80 82
## 4 3 VenusaurMega Venusaur Grass Poison 625 80 100
## 5 43 Oddish Grass Poison 320 45 50
## 6 44 Gloom Grass Poison 395 60 65
## 7 45 Vileplume Grass Poison 490 75 80
## 8 46 Paras Bug Grass 285 35 70
## 9 47 Parasect Bug Grass 405 60 95
## 10 69 Bellsprout Grass Poison 300 50 75
## 11 70 Weepinbell Grass Poison 390 65 90
## 12 71 Victreebel Grass Poison 490 80 105
## 13 102 Exeggcute Grass Psychic 325 60 40
## 14 103 Exeggutor Grass Psychic 520 95 95
## 15 114 Tangela Grass <NA> 435 65 55
## 16 152 Chikorita Grass <NA> 318 45 49
## 17 153 Bayleef Grass <NA> 405 60 62
## 18 154 Meganium Grass <NA> 525 80 82
## 19 182 Bellossom Grass <NA> 490 75 80
## 20 187 Hoppip Grass Flying 250 35 35
## 21 188 Skiploom Grass Flying 340 55 45
## 22 189 Jumpluff Grass Flying 460 75 55
## 23 191 Sunkern Grass <NA> 180 30 30
## 24 192 Sunflora Grass <NA> 425 75 75
## 25 251 Celebi Psychic Grass 600 100 100
## 26 252 Treecko Grass <NA> 310 40 45
## 27 253 Grovyle Grass <NA> 405 50 65
## 28 254 Sceptile Grass <NA> 530 70 85
## 29 254 SceptileMega Sceptile Grass Dragon 630 70 110
## 30 270 Lotad Water Grass 220 40 30
## 31 271 Lombre Water Grass 340 60 50
## 32 272 Ludicolo Water Grass 480 80 70
## 33 273 Seedot Grass <NA> 220 40 40
## 34 274 Nuzleaf Grass Dark 340 70 70
## 35 275 Shiftry Grass Dark 480 90 100
## 36 285 Shroomish Grass <NA> 295 60 40
## 37 286 Breloom Grass Fighting 460 60 130
## 38 315 Roselia Grass Poison 400 50 60
## 39 331 Cacnea Grass <NA> 335 50 85
## 40 332 Cacturne Grass Dark 475 70 115
## 41 345 Lileep Rock Grass 355 66 41
## 42 346 Cradily Rock Grass 495 86 81
## 43 357 Tropius Grass Flying 460 99 68
## 44 387 Turtwig Grass <NA> 318 55 68
## 45 388 Grotle Grass <NA> 405 75 89
## 46 389 Torterra Grass Ground 525 95 109
## 47 406 Budew Grass Poison 280 40 30
## 48 407 Roserade Grass Poison 515 60 70
## 49 413 WormadamPlant Cloak Bug Grass 424 60 59
## 50 420 Cherubi Grass <NA> 275 45 35
## 51 421 Cherrim Grass <NA> 450 70 60
## 52 455 Carnivine Grass <NA> 454 74 100
## 53 459 Snover Grass Ice 334 60 62
## 54 460 Abomasnow Grass Ice 494 90 92
## 55 460 AbomasnowMega Abomasnow Grass Ice 594 90 132
## 56 465 Tangrowth Grass <NA> 535 100 100
## 57 470 Leafeon Grass <NA> 525 65 110
## 58 479 RotomMow Rotom Electric Grass 520 50 65
## 59 492 ShayminLand Forme Grass <NA> 600 100 100
## 60 492 ShayminSky Forme Grass Flying 600 100 103
## 61 495 Snivy Grass <NA> 308 45 45
## 62 496 Servine Grass <NA> 413 60 60
## 63 497 Serperior Grass <NA> 528 75 75
## 64 511 Pansage Grass <NA> 316 50 53
## 65 512 Simisage Grass <NA> 498 75 98
## 66 540 Sewaddle Bug Grass 310 45 53
## 67 541 Swadloon Bug Grass 380 55 63
## 68 542 Leavanny Bug Grass 500 75 103
## 69 546 Cottonee Grass Fairy 280 40 27
## 70 547 Whimsicott Grass Fairy 480 60 67
## 71 548 Petilil Grass <NA> 280 45 35
## 72 549 Lilligant Grass <NA> 480 70 60
## 73 556 Maractus Grass <NA> 461 75 86
## 74 585 Deerling Normal Grass 335 60 60
## 75 586 Sawsbuck Normal Grass 475 80 100
## 76 590 Foongus Grass Poison 294 69 55
## 77 591 Amoonguss Grass Poison 464 114 85
## 78 597 Ferroseed Grass Steel 305 44 50
## 79 598 Ferrothorn Grass Steel 489 74 94
## 80 640 Virizion Grass Fighting 580 91 90
## 81 650 Chespin Grass <NA> 313 56 61
## 82 651 Quilladin Grass <NA> 405 61 78
## 83 652 Chesnaught Grass Fighting 530 88 107
## 84 672 Skiddo Grass <NA> 350 66 65
## 85 673 Gogoat Grass <NA> 531 123 100
## 86 708 Phantump Ghost Grass 309 43 70
## 87 709 Trevenant Ghost Grass 474 85 110
## 88 710 PumpkabooAverage Size Ghost Grass 335 49 66
## 89 710 PumpkabooSmall Size Ghost Grass 335 44 66
## 90 710 PumpkabooLarge Size Ghost Grass 335 54 66
## 91 710 PumpkabooSuper Size Ghost Grass 335 59 66
## 92 711 GourgeistAverage Size Ghost Grass 494 65 90
## 93 711 GourgeistSmall Size Ghost Grass 494 55 85
## 94 711 GourgeistLarge Size Ghost Grass 494 75 95
## 95 711 GourgeistSuper Size Ghost Grass 494 85 100
## 96 722 Rowlet Grass Flying 320 68 55
## 97 723 Dartrix Grass Flying 420 78 75
## 98 724 Decidueye Grass Ghost 530 78 107
## 99 753 Fomantis Grass <NA> 250 40 55
## 100 754 Lurantis Grass <NA> 480 70 105
## 101 755 Morelull Grass Fairy 285 40 35
## 102 756 Shiinotic Grass Fairy 405 60 45
## 103 761 Bounsweet Grass <NA> 210 42 30
## 104 762 Steenee Grass <NA> 290 52 40
## 105 763 Tsareena Grass <NA> 510 72 120
## 106 781 Dhelmise Ghost Grass 517 70 131
## 107 787 Tapu Bulu Grass Fairy 570 70 130
## 108 798 Kartana Grass Steel 570 59 181
## Defense SpecialAtk SpecialDef Speed Generation Legendary
## 1 49 65 65 45 1 FALSE
## 2 63 80 80 60 1 FALSE
## 3 83 100 100 80 1 FALSE
## 4 123 122 120 80 1 FALSE
## 5 55 75 65 30 1 FALSE
## 6 70 85 75 40 1 FALSE
## 7 85 110 90 50 1 FALSE
## 8 55 45 55 25 1 FALSE
## 9 80 60 80 30 1 FALSE
## 10 35 70 30 40 1 FALSE
## 11 50 85 45 55 1 FALSE
## 12 65 100 70 70 1 FALSE
## 13 80 60 45 40 1 FALSE
## 14 85 125 65 55 1 FALSE
## 15 115 100 40 60 1 FALSE
## 16 65 49 65 45 2 FALSE
## 17 80 63 80 60 2 FALSE
## 18 100 83 100 80 2 FALSE
## 19 95 90 100 50 2 FALSE
## 20 40 35 55 50 2 FALSE
## 21 50 45 65 80 2 FALSE
## 22 70 55 95 110 2 FALSE
## 23 30 30 30 30 2 FALSE
## 24 55 105 85 30 2 FALSE
## 25 100 100 100 100 2 FALSE
## 26 35 65 55 70 3 FALSE
## 27 45 85 65 95 3 FALSE
## 28 65 105 85 120 3 FALSE
## 29 75 145 85 145 3 FALSE
## 30 30 40 50 30 3 FALSE
## 31 50 60 70 50 3 FALSE
## 32 70 90 100 70 3 FALSE
## 33 50 30 30 30 3 FALSE
## 34 40 60 40 60 3 FALSE
## 35 60 90 60 80 3 FALSE
## 36 60 40 60 35 3 FALSE
## 37 80 60 60 70 3 FALSE
## 38 45 100 80 65 3 FALSE
## 39 40 85 40 35 3 FALSE
## 40 60 115 60 55 3 FALSE
## 41 77 61 87 23 3 FALSE
## 42 97 81 107 43 3 FALSE
## 43 83 72 87 51 3 FALSE
## 44 64 45 55 31 4 FALSE
## 45 85 55 65 36 4 FALSE
## 46 105 75 85 56 4 FALSE
## 47 35 50 70 55 4 FALSE
## 48 65 125 105 90 4 FALSE
## 49 85 79 105 36 4 FALSE
## 50 45 62 53 35 4 FALSE
## 51 70 87 78 85 4 FALSE
## 52 72 90 72 46 4 FALSE
## 53 50 62 60 40 4 FALSE
## 54 75 92 85 60 4 FALSE
## 55 105 132 105 30 4 FALSE
## 56 125 110 50 50 4 FALSE
## 57 130 60 65 95 4 FALSE
## 58 107 105 107 86 4 FALSE
## 59 100 100 100 100 4 TRUE
## 60 75 120 75 127 4 TRUE
## 61 55 45 55 63 5 FALSE
## 62 75 60 75 83 5 FALSE
## 63 95 75 95 113 5 FALSE
## 64 48 53 48 64 5 FALSE
## 65 63 98 63 101 5 FALSE
## 66 70 40 60 42 5 FALSE
## 67 90 50 80 42 5 FALSE
## 68 80 70 80 92 5 FALSE
## 69 60 37 50 66 5 FALSE
## 70 85 77 75 116 5 FALSE
## 71 50 70 50 30 5 FALSE
## 72 75 110 75 90 5 FALSE
## 73 67 106 67 60 5 FALSE
## 74 50 40 50 75 5 FALSE
## 75 70 60 70 95 5 FALSE
## 76 45 55 55 15 5 FALSE
## 77 70 85 80 30 5 FALSE
## 78 91 24 86 10 5 FALSE
## 79 131 54 116 20 5 FALSE
## 80 72 90 129 108 5 TRUE
## 81 65 48 45 38 6 FALSE
## 82 95 56 58 57 6 FALSE
## 83 122 74 75 64 6 FALSE
## 84 48 62 57 52 6 FALSE
## 85 62 97 81 68 6 FALSE
## 86 48 50 60 38 6 FALSE
## 87 76 65 82 56 6 FALSE
## 88 70 44 55 51 6 FALSE
## 89 70 44 55 56 6 FALSE
## 90 70 44 55 46 6 FALSE
## 91 70 44 55 41 6 FALSE
## 92 122 58 75 84 6 FALSE
## 93 122 58 75 99 6 FALSE
## 94 122 58 75 69 6 FALSE
## 95 122 58 75 54 6 FALSE
## 96 55 50 50 42 7 FALSE
## 97 75 70 70 52 7 FALSE
## 98 75 100 100 70 7 FALSE
## 99 35 50 35 35 7 FALSE
## 100 90 80 90 45 7 FALSE
## 101 55 65 75 15 7 FALSE
## 102 80 90 100 30 7 FALSE
## 103 38 30 38 32 7 FALSE
## 104 48 40 48 62 7 FALSE
## 105 98 50 98 72 7 FALSE
## 106 100 86 90 40 7 FALSE
## 107 115 85 95 75 7 TRUE
## 108 131 59 31 109 7 FALSE
# Graph depicting electric type pokemon
ggplot(data = Electric_pokemon) + geom_col(aes(x = Name, y = Total), position = "dodge") + labs(title = "Electric Pokemon", x = "Pokemon", y = "Stats")
# Graph depicting grass type pokemon
ggplot(data = Grass_pokemon) + geom_col(aes(x = Name, y = Total), position = "dodge") + labs(title = "Grass Pokemon", x = "Pokemon", y = "Total")
Strongest_electric_pokemon <- filter(Electric_pokemon, Total == max(Total))
Strongest_electric_pokemon
## Number Name Type1 Type2 Total HP Attack Defense SpecialAtk
## 1 644 Zekrom Dragon Electric 680 100 150 120 120
## SpecialDef Speed Generation Legendary
## 1 100 90 5 TRUE
Weakest_electric_pokemon <- filter(Electric_pokemon, Total == min(Total))
Weakest_electric_pokemon
## Number Name Type1 Type2 Total HP Attack Defense SpecialAtk
## 1 172 Pichu Electric <NA> 205 20 40 15 35
## SpecialDef Speed Generation Legendary
## 1 35 60 2 FALSE
Strongest_grass_pokemon <- filter(Grass_pokemon, Total == max(Total))
Strongest_grass_pokemon
## Number Name Type1 Type2 Total HP Attack Defense
## 1 254 SceptileMega Sceptile Grass Dragon 630 70 110 75
## SpecialAtk SpecialDef Speed Generation Legendary
## 1 145 85 145 3 FALSE
Weakest_grass_pokemon <- filter(Grass_pokemon, Total == min(Total))
Weakest_grass_pokemon
## Number Name Type1 Type2 Total HP Attack Defense SpecialAtk SpecialDef
## 1 191 Sunkern Grass <NA> 180 30 30 30 30 30
## Speed Generation Legendary
## 1 30 2 FALSE
As we can see above, the strongest electric type pokemon is Zekrom and the strongest grass type pokemon is Mega Sceptile. When we compare the two we see that Zekrom is stronger than Mega Sceptile based on the total stats as well as every other stat except for special attack and speed. The weakest electric type pokemon is Pichu and the weakest grass type pokemon is Sunkern. Pichu is stronger than Sunkern based on total stats as well as every other stat except fo HP and defense. Note that for the strongest electric type pokemon is legendary and the strongest grass type pokemon isn’t. Both of the weakest electric and grass type pokemon are not legendary.