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.


手把手教你写高质量技术博客,画图工具,录像工具,Markdown写法... 前言 写博客是一件很有意义的事情,可以加深自己对技术的理解,可以结交更多的朋友,记录自己的技术轨迹,而且分享可以让更多的人从中受益,独乐乐不如众乐乐嘛。 但是要写好博客也不是件容易的事,一是写博客是长期坚持的过程,心血来潮写个一两篇并没有什么意义,很多人写着写着就放弃了,二是写博客需要自己用...
Error for jQuery ajax () if it g... I have met some problem with jQuery ajax() in Safari, so I created some simple code to test. A request is sent to PHP file and after 10 seconds, ...
基于Elastalert的安全告警剖析 *本文作者:bigface,本文属 FreeBuf 原创奖励计划,未经许可禁止转载。 elastalert 是 一款基于elasticsearch的开源告警产品( 官方说明文档 )。相信许多人都会使用ELK做日志收集系统,但是产生一个基于日志的“优秀”的安全告警确是一个难题。告警规则难编...
Jquery Sliding Panel Plugin JavaScript or jQuery Sliding Control This is not a question about sliding panels. This is a question about sliding controls that...
Get Protrusion and Collision data from Jquery Coll... I'm using Jquery Draggable Collision ( found here ) and I am trying to resize the draggable area (blue square, in my JSFiddle) via a simple toggle...