Hello, Dorling! (Creating Dorling Cartograms from R Spatial Objects + Introducing Prism Ske…

综合技术 2018-06-04 阅读原文

NOTE: There is some iframe
d content in this post and you canbust out of it if you want to see the document in a full browser window.

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.

And So It Begins

After seeing Fira Sans in action in presentations at eRum 2018
I felt compelled to add support hrbrthemes
support for it so I made a

extension to it that uses Fira Sans Condensed and Fira Code fonts for ggplot2 graphics.

But I rly wanted to go the extra mile and make an R Markdown theme for it, but I’m weary of both jQuery & Bootstrap, plus prefer Prism
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

but the “production” version is likely going to eventually go into the firasans
package. I uses markdowntemplates
as a playground for R Markdown experiments.

The source for the iframe
at the end of this document is here: https://rud.is/dl/hello-dorling.Rmd
. There are some notable features (I’ll repeat a few from above):

  • Fira Sans for headers and text
  • Fira Code for all monospaced content (including source code)
  • No jQuery
  • No Bootstrap (it uses the ‘Skeleton’ CSS framework)
  • No HighightJS (it uses the ‘Prism” highlighter)
  • Extended YAML parameters (more on that in a bit)
  • Defaults to fig.retina=2
    and the use of optipng
    or pngquant
    for PNG compression (so it expects them to be installed — ref this post by Zev Ross
    for more info and additional image use tips)

“What’s this about ‘Dorling’?”

Oh, yes. You can read the iframe
orbusted out document for that bit. It’s a small package to make it easier to create Dorling cartograms based on previous work by @datagistips

“You said something about ‘extended YAML’?”

Aye. Here’s the YAML excerpt from theDorling Rmd:

title: "Hello, Dorling! (Creating Dorling Cartograms from R Spatial Objects)"
author: "boB Rudis"
navlink: "[rud.is](https://rud.is/b/)"
  type: "article"
  title: "Hello, Dorling! (Creating Dorling Cartograms from R Spatial Objects)"
  url: "https://github.com/hrbrmstr/spdorling"
  - content: '[GitLab](https://gitlab.com/hrbrmstr)
  - content: 'This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.'
date: "`r Sys.Date()`"
output: markdowntemplates::prismskel

The title
, author
& date
should be familiar fields but the author
and date
get some different placement since the goal is more of a flowing document than academic report.

If navlink
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 navlink
and no bar will be there.

The og
section is for open graph
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.

There’s also a custom footer
(exclude it if you don’t want one) that can take multiple content

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 knitr
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.

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).


(Well, almost fin

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 spdorling
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.

As noted a few times, the Rmd example with the Dorling cartograms is below.

责编内容by:rud.is 【阅读原文】。感谢您的支持!


Current slide to materialize cuss carrousel How to get the current slide not in Glide.js Hi how can I ...
Pod定义与ConfigMap 荐 Pod的作用在k8s中pod是最小的管理单位,在一个pod中通常会包含一个或多个容器。 在每一个Pod中都有一个特殊的Pause容器和...
Powerful Help of Jquery to Develop Easy-To-Navigat... The earlier mobile world has been replaced today and now it is we...
Limit jquery get text ()&sem... I would like to use jQuery's .text() method to get my text contents of div e...
Add a Local File Picker to Image Dialog in TinyMCE TinyMCE is web-based WYSIWYG editor that converts HTML elements to an editor. I...