knitr::opts_chunk$set(echo = F,
                      warning = F,
                      message = F,
                      fig.align = "center")
## Load the required package: tidyverse
library(tidyverse)
## Reading in the pokedex for almost 700 pokemon from github
pokedex <- 
  # Data set
  read.csv('https://raw.githubusercontent.com/Shammalamala/DS-2870-Data-Sets/refs/heads/main/pokedex.csv') |> 
  # Adding a coupe of columns for later questions
  mutate(
    # Matching the gen number to the two main games in the franchise
    debut_game = case_when(
      generation == 1 ~ 'Red/Blue',
      generation == 2 ~ 'Gold/Silver',
      generation == 3 ~ 'Ruby/Sapphire',
      generation == 4 ~ 'Diamond/Pearl',
      generation == 5 ~ 'Black/White',
      generation == 6 ~ 'X/Y'
    ),
    # Adding a column to indicate which of the 'main types' a pokemon is, if any
    main_type = case_when(
      type1 == 'Grass'  | type2 == 'Grass' ~ 'Grass',
      type1 == 'Water'  | type2 == 'Water' ~ 'Water',
      type1 == 'Fire'   | type2 == 'Fire'  ~ 'Fire',
      type1 == 'Bug'    | type2 == 'Bug'   ~ 'Bug',
      type1 == 'Normal'                    ~ 'Normal',
      .default = 'Other'
    ) |> factor(levels = c('Fire', 'Water', 'Grass', 'Bug', 'Normal', 'Other')),
    
    # Changing legendary to be 'Legendary'/'Not Legendary' instead of T/F
    legendary = if_else(legendary, 'Legendary', 'Not Legendary'),
    # Changing hectograms to ounces and decimeters to inches
    weight = weight * 3.5274,
    height = height * 3.93701
  )
The pokedex data set has the information on 697 Pokemon up to generation 6 (X & Y). The relevant columns for this assignment are:
number: the unique identifier for the pokemon in the
data setname: the name of the pokemontype1 and type2: Which of 17 different
types a pokemon can be (many have two types)assessed_value: The value of the property assessed by
the town for tax purposeshp, attack, defense,
sp_atk, sp_def, and speed: the
base combat attributesgeneration and debut_game: Which game the
pokemon debuted in.height and weight: The size of each
pokemon (in inches and ounces, respectively)sprites: a url to an image of each pokemon in sprite
formmain_type: Which of the 5 most common types
(Water/Grass/Fire/Bug/Normal/Other) a pokemon is based on
type1 or type2Create a bar chart for each generation 1 - 6. See what it should look like in Brightspace
Use the following vectors in the appropriate function to
match the bar colors:
fill =  c('#ff1111', '#daa520', '#a00000', '#aaaaff', '#444444', '#6376b8')
color = c('#1111ff', '#c0c0c0', '#0000a0', '#ffaaaa', '#e1e1e1', '#ed5540')
Create the graph seen in question 2 in Brightspace. The color codes for each type are:
'Normal' = '#a8a77a',
'Grass'  = '#7ac74c',
'Water'  = '#6390F0',
'Fire'   = '#EE8130',
'Bug'    = '#a6b91a',
'Other'  = '#6f35fc'
Which games had a fewest Fire types introduced as a percentage of new pokemon?
Create the graph seen in Brightspace. The colors for
main_type are the same as question 2.
Create the graph seen in Brightspace. The values on the x and y-axis are the z-scores for HP and speed calculated using all 697 pokemon.
\[z = (x - \mu_x)/\sigma_x\]
The graph displays only the 38 legendary.
You can add vertical and horizontal lines using
geom_vline(xintercept) and
geom_hline(yintercept) respectively.