<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/pokemon-and-trelliscopejs/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://ryanhafen.com/blog/pokemon"> Ryan Hafen</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p></p>
<p>I’m always looking for ways to spark my kid’s interest in computers, data, etc. This has proven to be more difficult than I thought it would be (kids these days…). I suspect this may have something to do with the ubiquity of electronic devices that “just work”, making them less novel and less interesting to tinker with, but speculation on this is a post for another time…</p>
<p>Anyway, all of my kids are crazy into Pokemon so when I came across some Pokemon data the other day that leant itself very nicely to a Trelliscope display, I thought I might have a chance to engage them. And then I thought why not write a post about it. You can find the resulting display and code to recreate it in this post. Hope you enjoy!</p>
<p><span></span></p>
<p>To start out, here’s the display:</p>
<div>
<div></div>
</div>
<p>If this display doesn’t appear correctly for you (because of blog aggregators, etc.), you can follow <a target="_blank" rel="nofollow" href="http://hafen.github.io/trelliscopejs-demo/pokemon/">this link</a> to the display in a dedicated window. For better viewing, you can also click the bottom right “fullscreen” button to expand the display to fill the window.</p>
<p>The data from which this was created is a simple data frame of Pokemon statistics, based on <a target="_blank" rel="nofollow" href="https://github.com/DaveRGP/pokRdex/blob/master/pokRdex.csv">this source</a> (which borrows from <a target="_blank" rel="nofollow" href="http://jkunst.com/r/pokemon-visualize-em-all/">here</a>). I <a target="_blank" rel="nofollow" href="https://github.com/hafen/pokRdex/blob/master/pokRdex_mod.csv">slightly modified</a> the data to add some variables that enhance the display (I changed the image URL to a better source, added a variable “pokedex” that provides a link to the pokemon’s pokedex entry on <a target="_blank" rel="nofollow" href="http://www.pokemon.com/us/pokedex/">pokemon.com</a>, and removed a few special Pokemon that I couldn’t find on pokedex).</p>
<p>Since this data is simply a data frame where each row refers to a Pokemon, it lends itself nicely to a Trelliscope display showing an image of the Pokemon as the panel and allowing interaction with the Pokemon being viewed based on the various statistics provided.</p>
<p>Here’s the code to make the display. Once the data is read, it’s just a few lines.</p>
<pre><code># install packages if not installed
devtools::install_github(&quot;hafen/trelliscopejs&quot;)
install.packages(c(&quot;readr&quot;, &quot;dplyr&quot;))

library(readr)
library(dplyr)
library(trelliscopejs)

# read the data (making &quot;_id&quot; columns strings)
pok &lt;-
  read_csv(&quot;https://raw.githubusercontent.com/hafen/pokRdex/master/pokRdex_mod.csv&quot;) %>%
  mutate_at(vars(matches(&quot;_id$&quot;)), as.character)

# take a look
glimpse(pok)
</code></pre>
<pre><code>Observations: 801
Variables: 30
$ pokemon                 &lt;chr> &quot;bulbasaur&quot;, &quot;ivysaur&quot;, &quot;venusaur&quot;, &quot;ve...
$ id                      &lt;int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ...
$ species_id              &lt;chr> &quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;6&quot;,...
$ height                  &lt;int> 7, 10, 20, 24, 6, 11, 17, 17, 17, 5, 10...
$ weight                  &lt;int> 69, 130, 1000, 1555, 85, 190, 905, 1105...
$ base_experience         &lt;int> 64, 142, 236, 281, 62, 142, 240, 285, 2...
$ type_1                  &lt;chr> &quot;grass&quot;, &quot;grass&quot;, &quot;grass&quot;, &quot;grass&quot;, &quot;fi...
$ type_2                  &lt;chr> &quot;poison&quot;, &quot;poison&quot;, &quot;poison&quot;, &quot;poison&quot;,...
$ attack                  &lt;int> 49, 62, 82, 100, 52, 64, 84, 130, 104, ...
$ defense                 &lt;int> 49, 63, 83, 123, 43, 58, 78, 111, 78, 6...
$ hp                      &lt;int> 45, 60, 80, 80, 39, 58, 78, 78, 78, 44,...
$ special_attack          &lt;int> 65, 80, 100, 122, 60, 80, 109, 130, 159...
$ special_defense         &lt;int> 65, 80, 100, 120, 50, 65, 85, 85, 115, ...
$ speed                   &lt;int> 45, 60, 80, 80, 65, 80, 100, 100, 100, ...
$ ability_1               &lt;chr> &quot;overgrow&quot;, &quot;overgrow&quot;, &quot;overgrow&quot;, &quot;th...
$ ability_2               &lt;chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,...
$ ability_hidden          &lt;chr> &quot;chlorophyll&quot;, &quot;chlorophyll&quot;, &quot;chloroph...
$ color_1                 &lt;chr> &quot;#78C850&quot;, &quot;#78C850&quot;, &quot;#78C850&quot;, &quot;#78C8...
$ color_2                 &lt;chr> &quot;#A040A0&quot;, &quot;#A040A0&quot;, &quot;#A040A0&quot;, &quot;#A040...
$ color_f                 &lt;chr> &quot;#81A763&quot;, &quot;#81A763&quot;, &quot;#81A763&quot;, &quot;#81A7...
$ egg_group_1             &lt;chr> &quot;monster&quot;, &quot;monster&quot;, &quot;monster&quot;, &quot;monst...
$ egg_group_2             &lt;chr> &quot;plant&quot;, &quot;plant&quot;, &quot;plant&quot;, &quot;plant&quot;, &quot;dr...
$ url_image               &lt;chr> &quot;http://assets.pokemon.com/assets/cms2/...
$ generation_id           &lt;chr> &quot;1&quot;, &quot;1&quot;, &quot;1&quot;, NA, &quot;1&quot;, &quot;1&quot;, &quot;1&quot;, NA, N...
$ evolves_from_species_id &lt;chr> NA, &quot;1&quot;, &quot;2&quot;, NA, NA, &quot;4&quot;, &quot;5&quot;, NA, NA,...
$ evolution_chain_id      &lt;chr> &quot;1&quot;, &quot;1&quot;, &quot;1&quot;, NA, &quot;2&quot;, &quot;2&quot;, &quot;2&quot;, NA, N...
$ shape_id                &lt;chr> &quot;8&quot;, &quot;8&quot;, &quot;8&quot;, NA, &quot;6&quot;, &quot;6&quot;, &quot;6&quot;, NA, N...
$ shape                   &lt;chr> &quot;quadruped&quot;, &quot;quadruped&quot;, &quot;quadruped&quot;, ...
$ pokebase                &lt;chr> &quot;bulbasaur&quot;, &quot;ivysaur&quot;, &quot;venusaur&quot;, &quot;ve...
$ pokedex                 &lt;chr> &quot;http://www.pokemon.com/us/pokedex/bulb...
</code></pre>
<p>Now we can create a Trelliscope display by specifying <code>url_image</code> as the source for the panel images. We also specify a default <code>state</code> indicating that the values for the variables <code>pokemon</code> and <code>pokedex</code> should be shown as labels by default.</p>
<pre><code>pok %>%
  mutate(panel = img_panel(url_image)) %>%
  trelliscope(&quot;pokemon&quot;, nrow = 3, ncol = 6,
    state = list(labels = c(&quot;pokemon&quot;, &quot;pokedex&quot;)))
</code></pre>
<p>This will produce the interactive plot shown at the top of this post. You can use the display to find Pokemon based on sorting or filtering on several of their attributes.</p>
<p>Note that despite my kids constantly telling me about and showing me their Pokemon cards, I am not a Pokemon expert, so there may be some interesting things I am missing. But I can say that my kids were finally impressed and engaged with something that I showed them. Success!</p>
<p>If this is your first exposure to Trelliscope and you are interested in other things it can do, please see my <a target="_blank" rel="nofollow" href="http://ryanhafen.com/blog/trelliscopejs">original blog post</a>.</p>
<p>This is my last post of the year. Happy new year!</p>
<p></p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://ryanhafen.com/blog/pokemon"> Ryan Hafen</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/A_2fwJXVUfY"></a></div>