<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/hello-dorling-creating-dorling-cartograms-from-r-spatial-objects-introducing-prism-skeleton/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://rud.is/b/2018/06/03/hello-dorling-creating-dorling-cartograms-from-r-spatial-objects-introducing-prism-skeleton/"> R – rud.is</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<hr>
<p><em>NOTE: There is some <code>iframe</code>d content in this post and you can <a rel="nofollow" href="https://rud.is/rpubs/hello-dorling.html" target="_blank">bust out of it</a> if you want to see the document in a full browser window.</em></p>
<p><em>Also, apologies for some lingering GitHub links. I’m waiting for all the repos to import into to other services and haven’t had time to setup my own self-hosted public instance of any community-usable git-ish environment yet.</em></p>
<hr>
<h3>And So It Begins</h3>
<p>After seeing Fira Sans in action in presentations at <a rel="nofollow" href="https://2018.erum.io/" target="_blank">eRum 2018</a> I felt compelled to add support <code>hrbrthemes</code> support for it so I made a <a rel="nofollow" href="https://github.com/hrbrmstr/firasans" target="_blank"><code>firasans</code><img alt="🔗" src="https://i2.wp.com/s.w.org/images/core/emoji/2.4/72x72/1f517.png?w=456&ssl=1" class="wp-smiley" data-recalc-dims="1"></a> extension to it that uses Fira Sans Condensed and Fira Code fonts for ggplot2 graphics.</p>
<p>But I rly wanted to go the extra mile and make an R Markdown theme for it, but I’m weary of both jQuery &amp; Bootstrap, plus prefer <a rel="nofollow" href="http://prismjs.com/" target="_blank">Prism</a> over HighlightJS. So I started work on “Prism Skeleton”, which is an R Markdown template that has most of the features you would expect and some new ones, plus used Prism and Fira Sans/Code. You can try it out on your own if you use <a rel="nofollow" href="https://github.com/hrbrmstr/markdowntemplates" target="_blank"><code>markdowntemplates</code><img alt="🔗" src="https://i2.wp.com/s.w.org/images/core/emoji/2.4/72x72/1f517.png?w=456&ssl=1" class="wp-smiley" data-recalc-dims="1"></a> but the “production” version is likely going to eventually go into the <code>firasans</code> package. I uses <code>markdowntemplates</code> as a playground for R Markdown experiments.</p>
<p>The source for the <code>iframe</code> at the end of this document is here: <a rel="nofollow" href="https://rud.is/dl/hello-dorling.Rmd" target="_blank">https://rud.is/dl/hello-dorling.Rmd</a>. There are some notable features (I’ll repeat a few from above):</p>
<ul>
<li>Fira Sans for headers and text</li>
<li>Fira Code for all monospaced content (including source code)</li>
<li>No jQuery</li>
<li>No Bootstrap (it uses the ‘Skeleton’ CSS framework)</li>
<li>No HighightJS (it uses the ‘Prism” highlighter)</li>
<li>Extended YAML parameters (more on that in a bit)</li>
<li>Defaults to <code>fig.retina=2</code> and the use of <code>optipng</code> or <code>pngquant</code> for PNG compression (so it expects them to be installed — ref <a rel="nofollow" href="https://www.zevross.com/blog/2017/06/19/tips-and-tricks-for-working-with-images-and-figures-in-r-markdown-documents/" target="_blank">this post by Zev Ross</a> for more info and additional image use tips)</li>
</ul>
<h3><em>“What’s this about ‘Dorling’?”</em></h3>
<p>Oh, yes. You can read the <code>iframe</code> or <a rel="nofollow" href="https://rud.is/rpubs/hello-dorling.html" target="_blank">busted out document</a> for that bit. It’s a small package to make it easier to create Dorling cartograms based on previous work by <a rel="nofollow" href="http://twitter.com/datagistips" target="_blank">@datagistips</a>.</p>
<h3><em>“You said something about ‘extended YAML’?”</em></h3>
<p>Aye. Here’s the YAML excerpt from the <a rel="nofollow" href="https://rud.is/dl/hello-dorling.Rmd" target="_blank">Dorling Rmd</a>:</p>
<pre>
---
title: &quot;Hello, Dorling! (Creating Dorling Cartograms from R Spatial Objects)&quot;
author: &quot;boB Rudis&quot;
navlink: &quot;[rud.is](https://rud.is/b/)&quot;
og:
  type: &quot;article&quot;
  title: &quot;Hello, Dorling! (Creating Dorling Cartograms from R Spatial Objects)&quot;
  url: &quot;https://github.com/hrbrmstr/spdorling&quot;
footer:
  - content: '[GitLab](https://gitlab.com/hrbrmstr)<br>'
  - content: 'This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.'
date: &quot;`r Sys.Date()`&quot;
output: markdowntemplates::prismskel
---
</pre>
<p>The <code>title</code>, <code>author</code> &amp; <code>date</code> should be familiar fields but the <code>author</code> and <code>date</code> get some different placement since the goal is more of a flowing document than academic report.</p>
<p>If <code>navlink</code> is present (it’s not required) there will be a static bar at the top of the HTML document with a link on the right (any content, really, but a link is what’s in the example). Remove <code>navlink</code> and no bar will be there.</p>
<p>The <code>og</code> section is for <a rel="nofollow" href="http://ogp.me/" target="_blank">open graph</a> tags and you customize them how you like. Open graph tags make it easier to share posts on social media or even Slack since they’ll auto-expand various content bits.</p>
<p>There’s also a custom <code>footer</code> (exclude it if you don’t want one) that can take multiple <code>content</code> sub-elements.</p>
<p>The goal isn’t so much to give you a 100% usable R Markdown template but something you can clone and customize for your own use. Since this example shows how to use custom fonts and a different code highlighter (which meant using some custom <code>knitr</code> hooks), it should be easier to customize than some of the other ones in the template playground package. FWIW I plan on adapting this for a work template this week.</p>
<p>The other big customization is the use of Prism with a dark theme. Again, you can clone + customize this at-will but I may add config options for all Prism themes at some point (mostly if there is interest).</p>
<h3>FIN</h3>
<p>(Well, almost <em>fin</em>)</p>
<p>Kick the tyres on both the new template and the new package and drop suggestions here for the time being (until I get fully transitioned to a new git-hosting platform). One TODO for <code>spdorling</code> is to increase the point count for the circle polygons but I’m sure folks can come up with enhancement requests to the API after y’all have played with it for a while.</p>
<p>As noted a few times, the Rmd example with the Dorling cartograms is below.</p>
<p><iframe src="https://rud.is/rpubs/hello-dorling.html"></iframe></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="https://rud.is/b/2018/06/03/hello-dorling-creating-dorling-cartograms-from-r-spatial-objects-introducing-prism-skeleton/"> R – rud.is</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 rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/ZyIS-z5P2GU" height="1"></a></div>