<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/cards-on-the-table/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://masalmon.github.io/2017/01/27/catan/"> Maëlle</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>After the <a target="_blank" rel="nofollow" href="http://www.masalmon.eu/2017/01/26/morewater/">last post</a> building on feedback from readers, the blog is back to the regular program of recycling old Github repos. Today’s project was waiting for its turn <a target="_blank" rel="nofollow" href="https://github.com/masalmon/catan_card_game">here</a> and will involve a Catan card game. Nearly a year ago, I played Catan with my husband who was kind enough to accept our monitoring all rounds. My goal? Producing a nice animated visualization of our game.</p>
<p><span></span></p>
<p>I’ll first reckon I don’t even really like card games, board games, you name it. I don’t hate them, but there are thousands other things that I’d rather do even when socializing, like talking or listening. Well in any case we received a game of Catan cards as a present, and it’s actually not a bad game. If you’re curious you can read <a target="_blank" rel="nofollow" href="https://en.wikipedia.org/wiki/Catan_Card_Game">this page</a>, for this article you only need to know that the game is about getting riches (lumber, grain, etc.) for your territory, which you gain by cards drawn from the market or exchanged with other players. The more riches your territory has, the bigger is your score. You stop playing when one of the players’ score is higher than a limit, or after 20 rounds because you’re too tired to monitor any more round.</p>
<h1>Collected data</h1>
<p>This is how the data we got looks like:</p>
<div>
<pre><code><span>market</span><span> </span><span>&lt;-</span><span> </span><span>readr</span><span>::</span><span>read_csv</span><span>(</span><span>&quot;data/2017-01-27-catan_market.csv&quot;</span><span>)</span><span>
</span><span>damien</span><span> </span><span>&lt;-</span><span> </span><span>readr</span><span>::</span><span>read_csv</span><span>(</span><span>&quot;data/2017-01-27-catan_damien.csv&quot;</span><span>)</span><span>
</span><span>maelle</span><span> </span><span>&lt;-</span><span> </span><span>readr</span><span>::</span><span>read_csv</span><span>(</span><span>&quot;data/2017-01-27-catan_maelle.csv&quot;</span><span>)</span><span>
</span><span>knitr</span><span>::</span><span>kable</span><span>(</span><span>head</span><span>(</span><span>damien</span><span>))</span><span>
</span></code></pre>
</div>
<table>
<thead>
<tr>
<th>victory</th>
<th>round</th>
<th>lumber</th>
<th>brick</th>
<th>grain</th>
<th>wool</th>
<th>ore</th>
<th>settlement</th>
<th>city</th>
<th>knight</th>
<th>city_hall</th>
<th>development</th>
<th>road</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1</td>
<td>3</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>3</td>
<td>1</td>
<td>2</td>
<td>0</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>4</td>
<td>1</td>
<td>2</td>
<td>0</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>5</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>6</td>
<td>0</td>
<td>1</td>
<td>0</td>
<td>2</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>3</td>
</tr>
</tbody>
</table>
<div>
<pre><code><span>knitr</span><span>::</span><span>kable</span><span>(</span><span>head</span><span>(</span><span>maelle</span><span>))</span><span>
</span></code></pre>
</div>
<table>
<thead>
<tr>
<th>victory</th>
<th>round</th>
<th>lumber</th>
<th>brick</th>
<th>grain</th>
<th>wool</th>
<th>ore</th>
<th>settlement</th>
<th>city</th>
<th>knight</th>
<th>city_hall</th>
<th>development</th>
<th>road</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
</tr>
<tr>
<td>1</td>
<td>3</td>
<td>0</td>
<td>2</td>
<td>0</td>
<td>0</td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
</tr>
<tr>
<td>1</td>
<td>4</td>
<td>0</td>
<td>2</td>
<td>0</td>
<td>0</td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
</tr>
<tr>
<td>1</td>
<td>5</td>
<td>0</td>
<td>2</td>
<td>0</td>
<td>1</td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
</tr>
<tr>
<td>1</td>
<td>6</td>
<td>0</td>
<td>2</td>
<td>0</td>
<td>1</td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>1</td>
</tr>
</tbody>
</table>
<p>For players for each turn one has a score which I called <em>victory</em> and a number of cards for each type of riches.</p>
<div>
<pre><code><span>knitr</span><span>::</span><span>kable</span><span>(</span><span>head</span><span>(</span><span>market</span><span>))</span><span>
</span></code></pre>
</div>
<table>
<thead>
<tr>
<th>round</th>
<th>lumber</th>
<th>brick</th>
<th>grain</th>
<th>wool</th>
<th>ore</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1</td>
<td>2</td>
<td>0</td>
<td>0</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>2</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>2</td>
</tr>
<tr>
<td>4</td>
<td>2</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>2</td>
</tr>
<tr>
<td>5</td>
<td>2</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>2</td>
</tr>
<tr>
<td>6</td>
<td>1</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>3</td>
</tr>
</tbody>
</table>
<p>The market has the same variables except <em>victory</em>. I even entered the number of cards of each types in tables but chose not to check the total numbers of our collected data made sense because I didn’t have any desire to monitor again, since it makes playing a bit too serious. I promise that this is not how I deal with scientific data.</p>
<h1>Design of the visualization</h1>
<p>The title of this section sounds fancier than my actual creative process, and well even creative process sounds fancy… Let’s say I had fun making decisions about my future viz. In my mind right from the beginning it was clear that I wanted to create a map of the territories where stuff would change over time to show the evolution of the scores.</p>
<h2>Choosing a representation of riches</h2>
<p>I am a big fan of the <a target="_blank" rel="nofollow" href="https://github.com/GuangchuangYu/emojifont"><code>emojifonts</code> package</a> so I decided to assign an emoji to each type of riches. It was not easy, sometimes emojis wouldn’t render, so I ended up with this list.</p>
<div>
<pre><code><span>emojis</span><span> </span><span>&lt;-</span><span> </span><span>readr</span><span>::</span><span>read_csv</span><span>(</span><span>&quot;data/2017-01-27-catan_emojis.csv&quot;</span><span>)</span><span>
</span><span>knitr</span><span>::</span><span>kable</span><span>(</span><span>emojis</span><span>)</span><span>
</span></code></pre>
</div>
<table>
<thead>
<tr>
<th>name</th>
<th>emoji</th>
</tr>
</thead>
<tbody>
<tr>
<td>lumber</td>
<td>evergreen_tree</td>
</tr>
<tr>
<td>brick</td>
<td>construction</td>
</tr>
<tr>
<td>grain</td>
<td>icecream</td>
</tr>
<tr>
<td>wool</td>
<td>sheep</td>
</tr>
<tr>
<td>ore</td>
<td>lemon</td>
</tr>
<tr>
<td>settlement</td>
<td>tent</td>
</tr>
<tr>
<td>city</td>
<td>house</td>
</tr>
<tr>
<td>knight</td>
<td>horse</td>
</tr>
<tr>
<td>city_hall</td>
<td>european_castle</td>
</tr>
<tr>
<td>development</td>
<td>japanese_castle</td>
</tr>
<tr>
<td>road</td>
<td>truck</td>
</tr>
</tbody>
</table>
<p>I’m in particular a bit ashamed of lemons as ore but I did not have a better idea. Lemons are not ore but they are a cool thing to own for your territory, okay?</p>
<h2>Which territories?</h2>
<p>I wanted to draw locations for the riches on a map. I did not want to draw my own territories, so I decided to use existing countries, actually three countries where my husband and I lived together: France, Germany, Spain. I got a file with many cities in the world <a target="_blank" rel="nofollow" href="http://www.opengeocode.org/download.php#cities">from this website</a> which I transformed using the following code.</p>
<div>
<pre><code><span>library</span><span>(</span><span>&quot;dplyr&quot;</span><span>)</span><span>
</span><span>cities</span><span> </span><span>&lt;-</span><span> </span><span>readr</span><span>::</span><span>read_csv</span><span>(</span><span>&quot;data/worldcities1.csv&quot;</span><span>)</span><span>
</span><span>names</span><span>(</span><span>cities</span><span>)</span><span> </span><span>&lt;-</span><span> </span><span>gsub</span><span>(</span><span>&quot; &quot;</span><span>,</span><span> </span><span>&quot;_&quot;</span><span>,</span><span> </span><span>names</span><span>(</span><span>cities</span><span>))</span><span>
</span><span>names</span><span>(</span><span>cities</span><span>)</span><span> </span><span>&lt;-</span><span> </span><span>gsub</span><span>(</span><span>&quot;-&quot;</span><span>,</span><span> </span><span>&quot;&quot;</span><span>,</span><span> </span><span>names</span><span>(</span><span>cities</span><span>))</span><span>
</span><span>cities</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>language_script</span><span> </span><span>%in%</span><span> </span><span>c</span><span>(</span><span>&quot;latin&quot;</span><span>,</span><span> </span><span>&quot;english&quot;</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>select</span><span>(</span><span>ISO_31661_country_code</span><span>,</span><span>
</span><span>name</span><span>,</span><span>
</span><span>latitude</span><span>,</span><span> </span><span>longitude</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>write_csv</span><span>(</span><span>path</span><span> </span><span>=</span><span> </span><span>&quot;data/2017-01-27-catan_.csv&quot;</span><span>)</span><span>
</span></code></pre>
</div>
<p>In this dataset for each city I get the country and longitudinal coordinates so it will be easy to get cities from the chosen countries.</p>
<h2>From the raw data to ready-to-plot data</h2>
<p>Since I was going to transform three similar tables, I decided to write functions. Well at the time I first made the viz I copy-pasted code three times but I decided it’d be better not to make my clumsiness public. Instead, I even started using the <code>dplyr</code> and <code>tidyr</code> functions with “_”, which I think looks professional.</p>
<p>The first step is to get from the wide to the long data, and to add emojis to each line. We thus have one line per round and riches type, with a number of cards for, say, lumber.</p>
<div>
<pre><code><span>library</span><span>(</span><span>&quot;tidyr&quot;</span><span>)</span><span>
</span><span>library</span><span>(</span><span>&quot;dplyr&quot;</span><span>)</span><span>
</span><span>add_emojis</span><span> </span><span>&lt;-</span><span> </span><span>function</span><span>(</span><span>df</span><span>,</span><span> </span><span>emojis</span><span>){</span><span>
</span><span>.dots</span><span> </span><span>&lt;-</span><span> </span><span>names</span><span>(</span><span>df</span><span>)[(</span><span>which</span><span>(</span><span>names</span><span>(</span><span>df</span><span>)</span><span> </span><span>==</span><span> </span><span>&quot;round&quot;</span><span>)</span><span> </span><span>+</span><span> </span><span>1</span><span>)</span><span>:</span><span>ncol</span><span>(</span><span>df</span><span>)]</span><span>
</span><span>df</span><span> </span><span>%>%</span><span> </span><span>gather_</span><span>(</span><span>&quot;what&quot;</span><span>,</span><span> </span><span>&quot;count&quot;</span><span>,</span><span> </span><span>.dots</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>left_join</span><span>(</span><span>emojis</span><span>,</span><span> </span><span>by</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;what&quot;</span><span> </span><span>=</span><span> </span><span>&quot;name&quot;</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>filter_</span><span>(</span><span>~</span><span> </span><span>count</span><span> </span><span>></span><span> </span><span>0</span><span>)</span><span>
</span><span>}</span><span>
</span></code></pre>
</div>
<p>The second step is to get one line per card of riches, because each of them will be plotted separately, and with an index number for cards of the same type in each round. Why? Well because if a territory had 1 card of lumber and then 2 cards of lumber, at the second round I want the card of lumber from the first round to stay at the same position.</p>
<div>
<pre><code><span>get_one_row_per_riches_unit</span><span> </span><span>&lt;-</span><span> </span><span>function</span><span>(</span><span>df</span><span>){</span><span>
</span><span>df</span><span> </span><span>&lt;-</span><span> </span><span>df</span><span>[</span><span>rep</span><span>(</span><span>seq_len</span><span>(</span><span>nrow</span><span>(</span><span>df</span><span>)),</span><span> </span><span>df</span><span>$</span><span>count</span><span>),]</span><span>
</span><span>df</span><span> </span><span>%>%</span><span>
</span><span>select_</span><span>(</span><span>quote</span><span>(</span><span>-</span><span> </span><span>count</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>group_by_</span><span>(</span><span>.dots</span><span> </span><span>=</span><span> </span><span>lapply</span><span>(</span><span>c</span><span>(</span><span>&quot;round&quot;</span><span>,</span><span> </span><span>&quot;what&quot;</span><span>,</span><span> </span><span>&quot;emoji&quot;</span><span>),</span><span> </span><span>as.symbol</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate_</span><span>(</span><span>which</span><span> </span><span>=</span><span> </span><span>~</span><span>1</span><span>:</span><span>n</span><span>())</span><span> </span><span>%>%</span><span>
</span><span>ungroup</span><span>()</span><span>
</span><span>}</span><span>
</span></code></pre>
</div>
<p>Then I draw cities from the territory for each card of lumber, card of ore, etc.</p>
<div>
<pre><code><span>cities</span><span> </span><span>&lt;-</span><span> </span><span>readr</span><span>::</span><span>read_csv</span><span>(</span><span>&quot;data/2017-01-27-catan_worldcities.csv&quot;</span><span>)</span><span>
</span><span>add_location</span><span> </span><span>&lt;-</span><span> </span><span>function</span><span>(</span><span>df</span><span>,</span><span> </span><span>country</span><span>,</span><span> </span><span>cities</span><span>){</span><span>
</span><span># get cities to put the things
</span><span> </span><span>tobelocated</span><span> </span><span>&lt;-</span><span> </span><span>df</span><span> </span><span>%>%</span><span>
</span><span>select_</span><span>(</span><span>.dots</span><span> </span><span>=</span><span> </span><span>list</span><span>(</span><span>&quot;what&quot;</span><span>,</span><span> </span><span>&quot;emoji&quot;</span><span>,</span><span> </span><span>&quot;which&quot;</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>unique</span><span>()</span><span>
</span><span>country</span><span> </span><span>&lt;-</span><span> </span><span>filter_</span><span>(</span><span>cities</span><span>,</span><span> </span><span>~</span><span>ISO_31661_country_code</span><span> </span><span>==</span><span> </span><span>country</span><span>)</span><span>
</span><span>set.seed</span><span>(</span><span>3</span><span>)</span><span>
</span><span>where</span><span> </span><span>&lt;-</span><span> </span><span>sample_n</span><span>(</span><span>country</span><span>,</span><span> </span><span>nrow</span><span>(</span><span>tobelocated</span><span>),</span><span>
</span><span>replace</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>)</span><span>
</span><span>tobelocated</span><span> </span><span>&lt;-</span><span> </span><span>cbind</span><span>(</span><span>where</span><span>,</span><span> </span><span>tobelocated</span><span>)</span><span> </span><span>df</span><span> </span><span>&lt;-</span><span> </span><span>left_join</span><span>(</span><span>df</span><span>,</span><span> </span><span>tobelocated</span><span>,</span><span>
</span><span>by</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;emoji&quot;</span><span>,</span><span> </span><span>&quot;which&quot;</span><span>,</span><span> </span><span>&quot;what&quot;</span><span>))</span><span>
</span><span>df</span><span> </span><span>&lt;-</span><span> </span><span>select_</span><span>(</span><span>df</span><span>,</span><span> </span><span>~</span><span>round</span><span>,</span><span> </span><span>~</span><span>what</span><span>,</span><span> </span><span>~</span><span>emoji</span><span>,</span><span>
</span><span>~</span><span>which</span><span>,</span><span> </span><span>~</span><span>latitude</span><span>,</span><span> </span><span>~</span><span>longitude</span><span>)</span><span> </span><span>return</span><span>(</span><span>df</span><span>)</span><span>
</span><span>}</span><span>
</span></code></pre>
</div>
<p>I also need to add the name of the participant.</p>
<div>
<pre><code><span>add_name</span><span> </span><span>&lt;-</span><span> </span><span>function</span><span>(</span><span>df</span><span>,</span><span> </span><span>name</span><span>){</span><span>
</span><span>mutate_</span><span>(</span><span>df</span><span>,</span><span> </span><span>who</span><span> </span><span>=</span><span> </span><span>~</span><span>name</span><span>)</span><span>
</span><span>}</span><span>
</span></code></pre>
</div>
<p>Once we have defined the functions, we can write a pretty <code>purrr</code> pipeline.</p>
<div>
<pre><code><span>library</span><span>(</span><span>&quot;purrr&quot;</span><span>)</span><span>
</span><span>map_data</span><span> </span><span>&lt;-</span><span> </span><span>list</span><span>(</span><span>market</span><span>,</span><span> </span><span>damien</span><span>,</span><span> </span><span>maelle</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>map</span><span>(</span><span>add_emojis</span><span>,</span><span> </span><span>emojis</span><span> </span><span>=</span><span> </span><span>emojis</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>map</span><span>(</span><span>get_one_row_per_riches_unit</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>map2</span><span>(</span><span>list</span><span>(</span><span>&quot;FR&quot;</span><span>,</span><span> </span><span>&quot;DE&quot;</span><span>,</span><span> </span><span>&quot;ES&quot;</span><span>),</span><span>
</span><span>add_location</span><span>,</span><span> </span><span>cities</span><span> </span><span>=</span><span> </span><span>cities</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>map2</span><span>(</span><span>list</span><span>(</span><span>&quot;Market&quot;</span><span>,</span><span> </span><span>&quot;Damien&quot;</span><span>,</span><span> </span><span>&quot;Maëlle&quot;</span><span>),</span><span>
</span><span>add_name</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>bind_rows</span><span>()</span><span>
</span><span>knitr</span><span>::</span><span>kable</span><span>(</span><span>head</span><span>(</span><span>map_data</span><span>))</span><span>
</span></code></pre>
</div>
<table>
<thead>
<tr>
<th>round</th>
<th>what</th>
<th>emoji</th>
<th>which</th>
<th>latitude</th>
<th>longitude</th>
<th>who</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>lumber</td>
<td>evergreen_tree</td>
<td>1</td>
<td>49.77894</td>
<td>3.213335</td>
<td>Market</td>
</tr>
<tr>
<td>2</td>
<td>lumber</td>
<td>evergreen_tree</td>
<td>1</td>
<td>49.77894</td>
<td>3.213335</td>
<td>Market</td>
</tr>
<tr>
<td>2</td>
<td>lumber</td>
<td>evergreen_tree</td>
<td>2</td>
<td>49.61031</td>
<td>0.354705</td>
<td>Market</td>
</tr>
<tr>
<td>3</td>
<td>lumber</td>
<td>evergreen_tree</td>
<td>1</td>
<td>49.77894</td>
<td>3.213335</td>
<td>Market</td>
</tr>
<tr>
<td>3</td>
<td>lumber</td>
<td>evergreen_tree</td>
<td>2</td>
<td>49.61031</td>
<td>0.354705</td>
<td>Market</td>
</tr>
<tr>
<td>4</td>
<td>lumber</td>
<td>evergreen_tree</td>
<td>1</td>
<td>49.77894</td>
<td>3.213335</td>
<td>Market</td>
</tr>
</tbody>
</table>
<p>I won’t lie, getting until this point was not all easy. When I read the code from so many months ago I was surprised to still understand it and quite proud of myself if I may say so.</p>
<h1>Draw the map!</h1>
<p>That’s where the <code>emojifonts</code> and <code>gganimate</code> magic happen. I don’t only plot riches, but also a crown for each territory whose size depends on the score of the territory.</p>
<div>
<pre><code><span>library</span><span>(</span><span>&quot;ggplot2&quot;</span><span>)</span><span>
</span><span>library</span><span>(</span><span>&quot;emojifont&quot;</span><span>)</span><span>
</span><span>## load selected emoji font
</span><span>load.emojifont</span><span>(</span><span>'OpenSansEmoji.ttf'</span><span>)</span><span>
</span><span>library</span><span>(</span><span>&quot;ggmap&quot;</span><span>)</span><span>
</span><span>library</span><span>(</span><span>&quot;gganimate&quot;</span><span>)</span><span>
</span><span>library</span><span>(</span><span>animation</span><span>)</span><span>
</span><span>map</span><span> </span><span>&lt;-</span><span> </span><span>get_map</span><span>(</span><span>location</span><span> </span><span>=</span><span> </span><span>&quot;France&quot;</span><span>,</span><span> </span><span>maptype</span><span> </span><span>=</span><span> </span><span>&quot;watercolor&quot;</span><span>,</span><span>
</span><span>zoom</span><span> </span><span>=</span><span> </span><span>5</span><span>)</span><span>
</span><span>p</span><span> </span><span>=</span><span> </span><span>ggmap</span><span>(</span><span>map</span><span>,</span><span> </span><span>extent</span><span> </span><span>=</span><span> </span><span>&quot;device&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_text</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>-</span><span> </span><span>9</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>44</span><span>,</span><span>
</span><span>label</span><span> </span><span>=</span><span> </span><span>&quot;Maëlland&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_text</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>7</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>54</span><span>,</span><span>
</span><span>label</span><span> </span><span>=</span><span> </span><span>&quot;Damienland&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_text</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>0</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>50.5</span><span>,</span><span>
</span><span>label</span><span> </span><span>=</span><span> </span><span>&quot;Market&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_text</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>damien</span><span>,</span><span>
</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>7</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>54.5</span><span>,</span><span>
</span><span>size</span><span> </span><span>=</span><span> </span><span>victory</span><span>,</span><span> </span><span>frame</span><span> </span><span>=</span><span> </span><span>round</span><span>),</span><span>
</span><span>label</span><span> </span><span>=</span><span> </span><span>emoji</span><span>(</span><span>&quot;crown&quot;</span><span>),</span><span> </span><span>family</span><span>=</span><span>'OpenSansEmoji'</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_text</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>maelle</span><span>,</span><span>
</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>-</span><span> </span><span>9</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>45</span><span>,</span><span>
</span><span>size</span><span> </span><span>=</span><span> </span><span>victory</span><span>,</span><span> </span><span>frame</span><span> </span><span>=</span><span> </span><span>round</span><span>),</span><span>
</span><span>label</span><span> </span><span>=</span><span> </span><span>emoji</span><span>(</span><span>&quot;crown&quot;</span><span>),</span><span> </span><span>family</span><span>=</span><span>'OpenSansEmoji'</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_text</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>map_data</span><span>,</span><span>
</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>longitude</span><span>,</span><span>
</span><span>y</span><span> </span><span>=</span><span> </span><span>latitude</span><span>,</span><span>
</span><span>label</span><span> </span><span>=</span><span> </span><span>emoji</span><span>(</span><span>emoji</span><span>),</span><span> </span><span>family</span><span>=</span><span>'OpenSansEmoji'</span><span>,</span><span>
</span><span>col</span><span> </span><span>=</span><span> </span><span>who</span><span>,</span><span>
</span><span>frame</span><span> </span><span>=</span><span> </span><span>round</span><span>),</span><span>
</span><span>size</span><span> </span><span>=</span><span> </span><span>5</span><span>)</span><span>+</span><span>
</span><span>theme</span><span>(</span><span>text</span><span> </span><span>=</span><span> </span><span>element_text</span><span>(</span><span>size</span><span>=</span><span>20</span><span>),</span><span>
</span><span>legend.position</span><span> </span><span>=</span><span> </span><span>&quot;none&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;Round&quot;</span><span>)</span><span>
</span><span>ani.options</span><span>(</span><span>interval</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>ani.width</span><span> </span><span>=</span><span> </span><span>400</span><span>,</span><span> </span><span>ani.height</span><span> </span><span>=</span><span> </span><span>400</span><span>)</span><span>
</span><span>gg_animate</span><span>(</span><span>p</span><span>,</span><span> </span><span>&quot;catan.gif&quot;</span><span>)</span><span>
</span></code></pre>
</div>
<p>And now, sit back and enjoy!</p>
<p><img alt="" src="https://i0.wp.com/github.com/masalmon/masalmon.github.io/blob/master/public/catan.gif?w=456&ssl=1" data-recalc-dims="1"></p>
<p>When I told <a target="_blank" rel="nofollow" href="https://twitter.com/milesmcbain">Miles McBain</a> about this visualization he told me it would be useful for post-game debriefing. So you’ll have to excuse me, I’ll now ask my husband if he wants to debrief the game we played 10 months ago.</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://masalmon.github.io/2017/01/27/catan/"> Maëlle</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/HTuE9BtOKRA"></a></div>