Project 2

Author

Phoebe Lam

##Pokemon Moon Visualization

Source: https://pokemondb.net/sun-moon

Source: https://pokemondb.net/sun-moon

The Pokemon franchise is widely known for pioneering the creature-collecting genre for video games. Pokemon Moon was part of a duo of games released in November 2016. It and it’s companion version, Pokemon Sun, served as the main title games of the 7th generation. Pokemon Sun and Moon brought 86 new creatures to collect, bringing the grand total at the time to about 800 different pokemon available in-game (“List of generation”). In Pokemon Moon, there is a function in the game where players may upload a pokemon to trade without knowing what they’ll receive in turn. These trades can connect from all over the world. This data-set compiles 500 random trades that one player did over the course of a week. It includes the pokemon name and their respective level, gender, types, and nature. Some interesting variables in this data-set include the Trainer region and Trainer Subregion, which details where the player traded this pokemon from. I chose this topic because I have always loved and played these games from a young age. Pokemon Moon is actually the only game I own from the 7th generation. I’m interested to learn about players’ thoughts and intentions while trading a pokemon, if any.

##Load and Clean Data-set

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
setwd("C:/Users/Phoeb/Downloads/Data 110/DatasetsData110")
pokemon_ <- read_csv("pokemon.csv")
Rows: 500 Columns: 15
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (10): Date, Pokemon, Trainer Region, Trainer Subregion, Pokemon Region,...
dbl   (3): Level, Level Met, Perfect IVs
lgl   (1): Held Item
time  (1): Time

ℹ 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.
pokemon_
# A tibble: 500 × 15
   Date      Time  Pokemon `Trainer Region` `Trainer Subregion` `Pokemon Region`
   <chr>     <tim> <chr>   <chr>            <chr>               <chr>           
 1 12/13/20… 17:28 Oricor… South Korea      <NA>                <NA>            
 2 12/13/20… 17:30 Zubat   United States    Texas               GER             
 3 12/13/20… 17:31 Carbink United States    Oklahoma            <NA>            
 4 12/13/20… 17:33 Klefki  United States    Connecticut         <NA>            
 5 12/13/20… 17:34 Luvdisc United States    <NA>                <NA>            
 6 12/13/20… 17:35 Roggen… United Kingdom   <NA>                SPA             
 7 12/13/20… 17:36 Saland… United States    California          <NA>            
 8 12/13/20… 17:38 Yungoos United States    Indiana             <NA>            
 9 12/13/20… 17:39 Wimpod  United States    New York            <NA>            
10 12/13/20… 17:41 Rowlet  France           <NA>                FRE             
# ℹ 490 more rows
# ℹ 9 more variables: Level <dbl>, `Level Met` <dbl>, Gender <chr>,
#   Type1 <chr>, Type2 <chr>, Nature <chr>, Pokeball <chr>, `Held Item` <lgl>,
#   `Perfect IVs` <dbl>
names(pokemon_) <- tolower(names(pokemon_))
names(pokemon_) <- gsub(" ","",names(pokemon_))
head(pokemon_)
# A tibble: 6 × 15
  date       time   pokemon   trainerregion trainersubregion pokemonregion level
  <chr>      <time> <chr>     <chr>         <chr>            <chr>         <dbl>
1 12/13/2016 17:28  Oricorio  South Korea   <NA>             <NA>             13
2 12/13/2016 17:30  Zubat     United States Texas            GER               8
3 12/13/2016 17:31  Carbink   United States Oklahoma         <NA>             10
4 12/13/2016 17:33  Klefki    United States Connecticut      <NA>             29
5 12/13/2016 17:34  Luvdisc   United States <NA>             <NA>             16
6 12/13/2016 17:35  Roggenro… United Kingd… <NA>             SPA              10
# ℹ 8 more variables: levelmet <dbl>, gender <chr>, type1 <chr>, type2 <chr>,
#   nature <chr>, pokeball <chr>, helditem <lgl>, perfectivs <dbl>

##Exploring Levels and IVs correlation

I noticed that there were 80 water type pokemon in a data-set of 500, when there are 18 total different types available in-game.

pkmn <- pokemon_ |>
  filter(type1 == 'Water') #removed all but water type pokemon

I wanted to see if there was a correlation between the level of a pokemon and the amount of perfect ivs they have.

lvliv <- pkmn |>
  ggplot(aes(x=perfectivs, y=level)) +
  geom_point(color = "#55aefe") +
  labs(x = "Number of Perfect IVs", y = "Level", title = "Traded Water Pokemon's Perfect IVs vs Level") 
lvliv

I wanted to use a bar chart for this visualization, to get rid of the awkward interval spacing. I opted for a scatter-plot in the end because the y-axis became the sum of the levels in a bar chart. This plot shows that most water pokemon have only 0 or 1 perfect ivs and that any pokemon with ivs greater than that are all at level 1.

Next, I want to see how all the other types available compares.

lvliv <- pokemon_ |>
  ggplot(aes(x=perfectivs, y=level, colour=type1)) +
  geom_point() +
  labs(x = "Number of Perfect IVs", y = "Level", title = "Traded Pokemon's Perfect IVs vs Level by Type", fill = "Type") +
  facet_wrap(vars(type1))
lvliv

Most of the types show the same trend, most pokemon are concentrated at 0 perfect ivs where there is a wider range of levels. Then it transitions to a steep incline as the amount of ivs increase, leading to most types having only level 1 pokemon when the ivs become >= 3. There is one interesting outlier in the Psychic type. There are only 2 pokemon in this data-set that have all 6 perfect ivs. One is called Salandit at level 1 and the other is our psychic outlier, Lunala at level 55. Unlike Salandit, there is only one encounter and one chance of catching Lunala in the game. The odds of that Lunala having all 6 perfect ivs is even rarer. Although, any pokemon with 6 perfect ivs are also extremely rare, there are other ways a player can acquire more common pokemon like Salandit as opposed to Lunala. The trade behind Lunala can be determined as a shocking and intentional trade.

##Exploring Breeding

One common way a player acquires mass amounts of one creature, is through breeding. They do this with the purpose of finding a “shiny” version of that pokemon (An offcolor version with the unaffectd odds of 1/4096) or one with perfect ivs. Sometimes even more dedicated players breed with the intention of acquiring a shiny pokemon with perfect ivs. The mass aquisition of pokemon fills up storage boxes, where pokemon are stored in-game. What players commonly do with these pokemon is put them up for trading. You can easily determine which pokemon have been acquired through breeding because only offspring pokemon are level 1.

I want to see which pokemon were coveted for shiny versions and/or perfect ivs at the time.

pokemonlvl <- pokemon_ |>
  filter(level==1) #remove all pokemon above level 1
pokemonlvl
# A tibble: 204 × 15
   date       time   pokemon  trainerregion trainersubregion pokemonregion level
   <chr>      <time> <chr>    <chr>         <chr>            <chr>         <dbl>
 1 12/13/2016 17:39  Wimpod   United States New York         <NA>              1
 2 12/13/2016 17:41  Rowlet   France        <NA>             FRE               1
 3 12/13/2016 17:42  Shinx    Germany       <NA>             GER               1
 4 12/13/2016 17:45  Mimikyu  Germany       <NA>             <NA>              1
 5 12/13/2016 17:51  A.Vulpix United States Louisiana        <NA>              1
 6 12/13/2016 17:54  A.Vulpix United States Illinois         JPN               1
 7 12/13/2016 17:57  Litten   United States New York         <NA>              1
 8 12/13/2016 18:05  Beldum   Japan         <NA>             JPN               1
 9 12/13/2016 18:13  Rowlet   United States Massachusetts    <NA>              1
10 12/13/2016 18:16  Grubbin  United States New York         <NA>              1
# ℹ 194 more rows
# ℹ 8 more variables: levelmet <dbl>, gender <chr>, type1 <chr>, type2 <chr>,
#   nature <chr>, pokeball <chr>, helditem <lgl>, perfectivs <dbl>
pokemonlvl2 <- pokemonlvl |>
  group_by(pokemon) |>
  summarize(number_bab = n()) #Counted number of rows for amount of each pokemon
pokemonlvl2
# A tibble: 65 × 2
   pokemon     number_bab
   <chr>            <int>
 1 A.Geodude            2
 2 A.Grimer             2
 3 A.Meowth             1
 4 A.Sandshrew          3
 5 A.Vulpix             9
 6 Abra                17
 7 Absol                2
 8 Bagon                5
 9 Beldum               3
10 Bounsweet            2
# ℹ 55 more rows
pkmnbab <- pokemonlvl2 |>
  filter(number_bab > 5) #Decided to look at pokemon w/ more than 5 trades, conveniently became top 10
pkmnbab
# A tibble: 10 × 2
   pokemon  number_bab
   <chr>         <int>
 1 A.Vulpix          9
 2 Abra             17
 3 Dewpider          6
 4 Eevee             7
 5 Gible             9
 6 Litten            9
 7 Magikarp          9
 8 Mimikyu          19
 9 Rowlet           12
10 Salandit          7
pkmnbabbar <- pkmnbab |>
  ggplot(aes(x = pokemon, y = number_bab, fill = pokemon)) +
  geom_bar(stat='identity') +
  labs(x = "Pokemon", y = "Number of Pokemon", title = "Top 10 Baby Pokemon Traded") +
  theme(axis.text.x = element_text(angle = 50))
pkmnbabbar

The most amount of offspring pokemon traded was Mimikyu, with Abra following close behind. 6 of these 10 pokemon were introduced in the 7th generation: Alolan Vulpix (A.Vulpix), Dewpider, Litten, Mimikyu, Rowlet, and Salandit. 3 of them are from the 1st generation: Abra, Eevee, and Magikarp. Gible is from generation 4. The 4 that are from previous games have had a lot of time to become a beloved classic, so I’m not surprised to see mass amounts of these being traded. Mimikyu seems to have become a fast favorite. I was not surprised at Abra being included in the top 10 but I was surprised at it being number 2 and the sheer amount it beats other pokemon by.

##Heatmap of Pokemon Trades

There’s quite a lot of Pokemon traded in the United States, I’m interested in which state has the most trades in comparison.

pokemonsubr <- pokemon_ |>
  drop_na(trainersubregion) #dropped those without trainersubregion
pokemonsubr
# A tibble: 143 × 15
   date       time   pokemon  trainerregion trainersubregion pokemonregion level
   <chr>      <time> <chr>    <chr>         <chr>            <chr>         <dbl>
 1 12/13/2016 17:30  Zubat    United States Texas            GER               8
 2 12/13/2016 17:31  Carbink  United States Oklahoma         <NA>             10
 3 12/13/2016 17:33  Klefki   United States Connecticut      <NA>             29
 4 12/13/2016 17:36  Salandit United States California       <NA>             19
 5 12/13/2016 17:38  Yungoos  United States Indiana          <NA>              7
 6 12/13/2016 17:39  Wimpod   United States New York         <NA>              1
 7 12/13/2016 17:50  Trumbeak United States Virginia         <NA>             22
 8 12/13/2016 17:51  A.Vulpix United States Louisiana        <NA>              1
 9 12/13/2016 17:54  A.Vulpix United States Illinois         JPN               1
10 12/13/2016 17:56  Abra     United States New York         <NA>              5
# ℹ 133 more rows
# ℹ 8 more variables: levelmet <dbl>, gender <chr>, type1 <chr>, type2 <chr>,
#   nature <chr>, pokeball <chr>, helditem <lgl>, perfectivs <dbl>
pokemonsubr2 <- pokemonsubr |>
  group_by(trainersubregion) |>
  summarise(count = n()) #counted amount of trades per state
pokemonsubr2
# A tibble: 38 × 2
   trainersubregion count
   <chr>            <int>
 1 Alabama              1
 2 Alaska               2
 3 California          15
 4 Colorado             3
 5 Connecticut          2
 6 DC                   1
 7 Delaware             1
 8 Florida              9
 9 Georgia              3
10 Idaho                1
# ℹ 28 more rows
library(dplyr)
pkmnsub <- pokemonsubr2 |>
  mutate(trainersubregion = tolower(trainersubregion)) #made all states lowercase to match upcoming dataset
pkmnsub
# A tibble: 38 × 2
   trainersubregion count
   <chr>            <int>
 1 alabama              1
 2 alaska               2
 3 california          15
 4 colorado             3
 5 connecticut          2
 6 dc                   1
 7 delaware             1
 8 florida              9
 9 georgia              3
10 idaho                1
# ℹ 28 more rows
library(mapproj)
Warning: package 'mapproj' was built under R version 4.4.1
Loading required package: maps
Warning: package 'maps' was built under R version 4.4.1

Attaching package: 'maps'
The following object is masked from 'package:purrr':

    map
library(maps)
states_map <- map_data("state") #loaded in u.s map data, with latitudes and longitudes of each state
pkmnmap <- merge(states_map, pkmnsub, by.x = "region", by.y = "trainersubregion") #combined both data frames by shared variable and then reordered columns
pkmnmap <- arrange(pkmnmap, group, order)              
pkmnheat <- ggplot(pkmnmap, aes(x = long, y = lat, group = group, fill = count)) +
  geom_polygon(colour = "black") +
  coord_map("polyconic") +
  labs(title = "Pokemon Moon Trades in the U.S", fill = "Trades", caption = "Source: Digimon Database") +
  scale_fill_gradient2(low = "#d8d5b2", mid = "gray", high = "#464699", midpoint = median(pkmnsub$count)) +
  theme(panel.background = element_rect(fill = "#d0e3f1"))
pkmnheat

The top three states with the most amount of pokemon traded are New York, California, and Texas. This isn’t very surprising since these states have the highest populations, of the United States. The rest of the map is very light in comparison to these 3 states. I decided to keep the median as the midpoint, just to show the disparity in amount of trades. The east coast is a little purply, it seems like they’re a little more active in trading in comparison to the flat grey mid-west.

##Pokemon Treemap

Pokemon are able to have two types, I wanted to include this aspect into a visualization. The second type can serve as sub-categories in a Treemap.

I made this visualization in Tableau: <https://public.tableau.com/app/profile/phoebe.lam3969/viz/PokemonMoonViz/TypesofPokemonTradedinPokemonMoon_1?publish=yes>

I made this visualization in Tableau: <https://public.tableau.com/app/profile/phoebe.lam3969/viz/PokemonMoonViz/TypesofPokemonTradedinPokemonMoon_1?publish=yes>

I made the types correspond to its respective official color in the Pokemon franchise. I also got rid of the redundant legend as it listed every single category and sub category combination. I added labels, so at a glance, it’s easy to tell which type occupies the most space. The interactive mouse tip lists the type, number of pokemon in each category, and the respective average level & average perfect ivs. We already know that type with the most pokemon traded is water. The normal type follows close behind. These two typings are double the size of the next type in line, the dark type. In most of these categories, pokemon with only one type are traded more than those in sub-categories. There are some notable types that have more pokemon traded in sub-categories. The Dark/Normal type, is all filled with A.Raticate/A.Rattata, which are one of the earliest and easiest to catch in-game. Poison/Fire and Ghost/Fairy can be attributed to Salandit and Mimikyu, as shown in the breeding bar chart.

##Closing Remarks

I think it’s safe to say that most of the pokemon put into trading by players are thoughtless. An overwhelming majority of pokemon are randomly put in with less than stellar stats(in reference to perfect ivs). Trading channels are flooded with offspring pokemon as a means to unclog a player’s storage. It’s all in good fun though and it makes getting a really good pokemon like Lunala through random trading even more exciting. I also have put in my own fair share of bad pokemon to trade. Most of the background information comes from personal experience, for exact numbers and dates, I referenced wikipedia. I do have some regrets with the U.S heatmap, I was unable to get the rest of the null state to appear and to have the state labeled with their abbreviations. I was also unable to change the font or customize it fully. I definitely would like to revisit this in the future and make it more visually appealing and interactive.

##Reference

Wikipedia contributors. (2024, May 23). List of generation VII Pokémon. In Wikipedia, The Free Encyclopedia. Retrieved 15:52, July 9, 2024, from https://en.wikipedia.org/w/index.php?title=List_of_generation_VII_Pok%C3%A9mon&oldid=1225321414