<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/french-villages-and-a-sort-of-resolution/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://masalmon.github.io/2017/01/24/kervillebourg/"> Maëlle</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<h1>Sort of introduction to this post and hopefully the next ones</h1>
<p>I usually don’t have any New Year resolution. However, <a target="_blank" rel="nofollow" href="https://twitter.com/_inundata/status/820713820310016000">recent</a> <a target="_blank" rel="nofollow" href="https://twitter.com/gdequeiroz/status/821766148655968256">tweets</a> about productivity – from people I actually find productive and inspiring – made me ponder a bit on my unfinished side projects. My main 2016 side-project was submitting and defending <a target="_blank" rel="nofollow" href="https://edoc.ub.uni-muenchen.de/19877/">my PhD thesis</a>, and I’ve written a few <a target="_blank" rel="nofollow" href="http://www.masalmon.eu/packages/">R packages</a>, so I’m overall quite happy.</p>
<p>But in 2016 I also started stuff without delivering. In particular, I prepared small data projects in Github repositories with a very precise README because I didn’t have a blog and planned to start one after my PhD thesis. Then I created my blog (thanks <a target="_blank" rel="nofollow" href="http://www.njtierney.com/jekyll/2015/11/11/how-i-built-my-site/">Nick</a>!) and… only re-posted <a target="_blank" rel="nofollow" href="http://www.masalmon.eu/2016/10/02/first7jobs-repost/">an analysis of mine</a> from another blog. My nice repositories are still lying around and they represent quite a few of my <a target="_blank" rel="nofollow" href="http://www.commitstrip.com/en/2014/11/25/west-side-project-story/">West Side-project Story unfinished buildings</a>. I’ve decided transforming some of my usable data projects into blog posts was a nice step towards being or at least feeling more productive.</p>
<p>Let’s start today with my visualizations of names of French villages!</p>
<p><span></span></p>
<p><em>Note: the analysis was originally prepared <a target="_blank" rel="nofollow" href="https://github.com/masalmon/kervillebourg">here</a> and advertised on <a target="_blank" rel="nofollow" href="https://twitter.com/ma_salmon/status/728660470798946304">Twitter</a></em></p>
<p>Inspired by <a target="_blank" rel="nofollow" href="https://github.com/hrbrmstr/zellingenach">this work about names of villages in Germany</a>, I wanted to have a look at the names of French villages. I decided against looking at prefixes and suffixes because I got a more poetical idea: looking for water and saints in my home country.</p>
<p>I got a file of all French villages names and geolocation from <a target="_blank" rel="nofollow" href="http://download.geonames.org/">Geonames</a>, which you can find in the <a target="_blank" rel="nofollow" href="http://masalmon.github.io/2017/01/24/kervillebourg/data/">data folder</a>. Thanks to Bob Rudis for providing me with <a target="_blank" rel="nofollow" href="https://gist.github.com/hrbrmstr/0fd37cf3825fc8e3eddf042a4443d1dc">the link</a>. The data is distributed under <a target="_blank" rel="nofollow" href="http://creativecommons.org/licenses/by/3.0/">this license</a>.</p>
<h1>A first look at the data</h1>
<div>
<pre><code><span>library</span><span>(</span><span>&quot;dplyr&quot;</span><span>)</span><span>
</span><span>library</span><span>(</span><span>&quot;tidyr&quot;</span><span>)</span><span>
</span><span>library</span><span>(</span><span>&quot;readr&quot;</span><span>)</span><span>
</span><span>ville</span><span> </span><span>&lt;-</span><span> </span><span>read_tsv</span><span>(</span><span>&quot;data/2017-01-24-kervillebourg_FR.txt&quot;</span><span>,</span><span> </span><span>col_names</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>)[,</span><span> </span><span>c</span><span>(</span><span>2</span><span>,</span><span> </span><span>5</span><span>,</span><span> </span><span>6</span><span>)]</span><span>
</span><span>names</span><span>(</span><span>ville</span><span>)</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>(</span><span>&quot;placename&quot;</span><span>,</span><span> </span><span>&quot;latitude&quot;</span><span>,</span><span> </span><span>&quot;longitude&quot;</span><span>)</span><span>
</span><span>knitr</span><span>::</span><span>kable</span><span>(</span><span>head</span><span>(</span><span>ville</span><span>))</span><span>
</span></code></pre>
</div>
<table>
<thead>
<tr>
<th>placename</th>
<th>latitude</th>
<th>longitude</th>
</tr>
</thead>
<tbody>
<tr>
<td>Recon, Col de</td>
<td>46.30352</td>
<td>6.82838</td>
</tr>
<tr>
<td>Lucelle</td>
<td>47.41667</td>
<td>7.50000</td>
</tr>
<tr>
<td>Les Cornettes de Bise</td>
<td>46.33333</td>
<td>6.78333</td>
</tr>
<tr>
<td>Ruisseau le Lertzbach</td>
<td>47.58333</td>
<td>7.58333</td>
</tr>
<tr>
<td>Le Cheval Blanc</td>
<td>46.05132</td>
<td>6.87178</td>
</tr>
<tr>
<td>Jougnena</td>
<td>46.71667</td>
<td>6.40000</td>
</tr>
</tbody>
</table>
<h1>Names of rivers and see</h1>
<p>Here I selected names of towns and villages that include the names of a few rivers in France, or the word “see” (“sur-Mer”). This is by no mean an exhaustive representation of such names since I only chose a few rivers and a single pattern of name.</p>
<p>I created new variables that are Booleans by looking for given pattern in names, like “sur-Mer”, then I only filtered the lines where one of the pattern was found, and used <code>tidyr::gather</code> function to end up with the long format you see below.</p>
<div>
<pre><code><span>water</span><span> </span><span>&lt;-</span><span> </span><span>ville</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>mer</span><span> </span><span>=</span><span> </span><span>grepl</span><span>(</span><span>&quot;sur-Mer&quot;</span><span>,</span><span> </span><span>placename</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>rhone</span><span> </span><span>=</span><span> </span><span>grepl</span><span>(</span><span>&quot;sur-Rhône&quot;</span><span>,</span><span> </span><span>placename</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>somme</span><span> </span><span>=</span><span> </span><span>grepl</span><span>(</span><span>&quot;sur-Somme&quot;</span><span>,</span><span> </span><span>placename</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>loire</span><span> </span><span>=</span><span> </span><span>grepl</span><span>(</span><span>&quot;sur-Loire&quot;</span><span>,</span><span> </span><span>placename</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>seine</span><span> </span><span>=</span><span> </span><span>grepl</span><span>(</span><span>&quot;sur-Seine&quot;</span><span>,</span><span> </span><span>placename</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>rhin</span><span> </span><span>=</span><span> </span><span>grepl</span><span>(</span><span>&quot;sur-Rhin&quot;</span><span>,</span><span> </span><span>placename</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>garonne</span><span> </span><span>=</span><span> </span><span>grepl</span><span>(</span><span>&quot;sur-Garonne&quot;</span><span>,</span><span> </span><span>placename</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>meuse</span><span> </span><span>=</span><span> </span><span>grepl</span><span>(</span><span>&quot;sur-Meuse&quot;</span><span>,</span><span> </span><span>placename</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>gather</span><span>(</span><span>&quot;name&quot;</span><span>,</span><span> </span><span>&quot;yes&quot;</span><span>,</span><span> </span><span>mer</span><span>:</span><span>meuse</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>yes</span><span> </span><span>==</span><span> </span><span>TRUE</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>select</span><span>(</span><span>-</span><span> </span><span>yes</span><span>)</span><span>
</span><span>knitr</span><span>::</span><span>kable</span><span>(</span><span>head</span><span>(</span><span>water</span><span>))</span><span>
</span></code></pre>
</div>
<table>
<thead>
<tr>
<th>placename</th>
<th>latitude</th>
<th>longitude</th>
<th>name</th>
</tr>
</thead>
<tbody>
<tr>
<td>Villers-sur-Mer</td>
<td>49.32264</td>
<td>0.00027</td>
<td>mer</td>
</tr>
<tr>
<td>Villefranche-sur-Mer</td>
<td>43.70470</td>
<td>7.30776</td>
<td>mer</td>
</tr>
<tr>
<td>Vierville-sur-Mer</td>
<td>49.37237</td>
<td>-0.90709</td>
<td>mer</td>
</tr>
<tr>
<td>Veulettes-sur-Mer</td>
<td>49.85162</td>
<td>0.59719</td>
<td>mer</td>
</tr>
<tr>
<td>Ver-sur-Mer</td>
<td>49.32987</td>
<td>-0.53118</td>
<td>mer</td>
</tr>
<tr>
<td>Vaux-sur-Mer</td>
<td>45.64606</td>
<td>-1.05841</td>
<td>mer</td>
</tr>
</tbody>
</table>
<p>Then I made an artsy map thanks to the <code>&quot;watercolor&quot;</code> <code>maptype</code> of <code>ggmap</code> and to my beloved <code>viridis</code>. The zoom I chose makes the map only for the <em>métrople</em>, I don’t even include Corsica.</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;ggmap&quot;</span><span>)</span><span>
</span><span>library</span><span>(</span><span>&quot;viridis&quot;</span><span>)</span><span>
</span><span>library</span><span>(</span><span>&quot;ggthemes&quot;</span><span>)</span><span>
</span><span>map</span><span> </span><span>&lt;-</span><span> </span><span>ggmap</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>zoom</span><span> </span><span>=</span><span> </span><span>6</span><span>,</span><span> </span><span>maptype</span><span> </span><span>=</span><span> </span><span>&quot;watercolor&quot;</span><span>)</span><span>
</span></code></pre>
</div>
<div>
<pre><code><span>ggmap</span><span>(</span><span>map</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_point</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>water</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>col</span><span> </span><span>=</span><span> </span><span>name</span><span>))</span><span> </span><span>+</span><span>
</span><span>scale_color_viridis</span><span>(</span><span>discrete</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span>option</span><span> </span><span>=</span><span> </span><span>&quot;plasma&quot;</span><span>)</span><span>+</span><span>
</span><span>theme_map</span><span>()</span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;French placenames containing the name of a river or 'see'&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>theme</span><span>(</span><span>plot.title</span><span> </span><span>=</span><span> </span><span>element_text</span><span>(</span><span>lineheight</span><span>=</span><span>1</span><span>,</span><span> </span><span>face</span><span>=</span><span>&quot;bold&quot;</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>14</span><span>))</span><span>
</span></code></pre>
</div>
<p><img alt="plot of chunk unnamed-chunk-5" src="https://i1.wp.com/masalmon.github.io/figure/source/2017-01-24-kervillebourg/unnamed-chunk-5-1.png?w=456" data-recalc-dims="1"></p>
<p>It was also, I must say, a nice lesson in French geography for me.</p>
<h1>Saint et Saintes</h1>
<p>In French, towns such as “Saint-Ouen” and “Sainte-Anne” can easily be partitioned into <em>cities named after a saint man</em> (saint) and <em>cities named after a saint woman</em> (sainte). Thinking of this prompted me to have a look at the distribution of such place names with a similar strategy than for rivers.</p>
<div>
<pre><code><span>saints</span><span> </span><span>&lt;-</span><span> </span><span>ville</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>saint</span><span> </span><span>=</span><span> </span><span>grepl</span><span>(</span><span>&quot;Saint-&quot;</span><span>,</span><span> </span><span>placename</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>sainte</span><span> </span><span>=</span><span> </span><span>grepl</span><span>(</span><span>&quot;Sainte-&quot;</span><span>,</span><span> </span><span>placename</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>gather</span><span>(</span><span>&quot;name&quot;</span><span>,</span><span> </span><span>&quot;yes&quot;</span><span>,</span><span> </span><span>saint</span><span>:</span><span>sainte</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>yes</span><span> </span><span>==</span><span> </span><span>TRUE</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>select</span><span>(</span><span>-</span><span> </span><span>yes</span><span>)</span><span>
</span><span>knitr</span><span>::</span><span>kable</span><span>(</span><span>head</span><span>(</span><span>saints</span><span>))</span><span>
</span></code></pre>
</div>
<table>
<thead>
<tr>
<th>placename</th>
<th>latitude</th>
<th>longitude</th>
<th>name</th>
</tr>
</thead>
<tbody>
<tr>
<td>Ygos-Saint-Saturnin</td>
<td>43.97651</td>
<td>-0.73780</td>
<td>saint</td>
</tr>
<tr>
<td>Canal de Vitry-le-François à Saint-Dizier</td>
<td>48.73333</td>
<td>4.60000</td>
<td>saint</td>
</tr>
<tr>
<td>Vitrac-Saint-Vincent</td>
<td>45.79585</td>
<td>0.49356</td>
<td>saint</td>
</tr>
<tr>
<td>Vineuil-Saint-Firmin</td>
<td>49.20024</td>
<td>2.49567</td>
<td>saint</td>
</tr>
<tr>
<td>Villotte-Saint-Seine</td>
<td>47.42893</td>
<td>4.70571</td>
<td>saint</td>
</tr>
<tr>
<td>Villiers-Saint-Denis</td>
<td>49.00000</td>
<td>3.26667</td>
<td>saint</td>
</tr>
</tbody>
</table>
<p>Here is the result on a map.</p>
<div>
<pre><code><span>ggmap</span><span>(</span><span>map</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_point</span><span>(</span><span>data</span><span> </span><span>=</span><span> </span><span>saints</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>+</span><span>
</span><span>theme_map</span><span>()</span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;Places named after a saint man or woman&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>theme</span><span>(</span><span>plot.title</span><span> </span><span>=</span><span> </span><span>element_text</span><span>(</span><span>lineheight</span><span>=</span><span>1</span><span>,</span><span> </span><span>face</span><span>=</span><span>&quot;bold&quot;</span><span>))</span><span> </span><span>+</span><span>
</span><span>facet_grid</span><span>(</span><span>.</span><span> </span><span>~</span><span> </span><span>name</span><span>)</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></code></pre>
</div>
<p><img alt="plot of chunk unnamed-chunk-7" src="https://i1.wp.com/masalmon.github.io/figure/source/2017-01-24-kervillebourg/unnamed-chunk-7-1.png?w=456" data-recalc-dims="1"></p>
<p>Well, I cannot say I’m surprised!</p>
<p>Back when I published this small work only on Github and Twitter, I was pleasantly surprised to see a <a target="_blank" rel="nofollow" href="https://github.com/ceresc/french-cities-names">more elaborate analysis</a> inspired by mine, so if this post made you curious about analysis of French placenames with R, head to Cérès Carton’s repository! And after this, I’ll just warn you to brace yourself for more old repos recycling from me.</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/24/kervillebourg/"> 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/PncXdzLpnyk"></a></div>