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
firasans
:link:

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
markdowntemplates
:link:

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/)"
og:
  type: "article"
  title: "Hello, Dorling! (Creating Dorling Cartograms from R Spatial Objects)"
  url: "https://github.com/hrbrmstr/spdorling"
footer:
  - 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
sub-elements.

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

FIN

(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 【阅读原文】。感谢您的支持!

您可能感兴趣的

Microsoft JScript runtime error: ‘... I am an ASP MVC 3 noobie working my way through the music store tutorial http://www.asp.net/mvc/tutorials/mvc-music-...
Jquery+Ajax+Bootstrap Paginator实现分页的拼接... 效果图如下 图片.png jsp页面引入bootstrap样式,jquery和bootstrap-paginator.js jsp页面代码,页面两个...
What you missed at satRday @Amsterdam As I spent an exciting day at satRday conference in Amsterdam I would like to share with you my thoughts. TL;DR: Eve...
JQuery – .attr is not a function Built a WordPress plugin that creates a custom-styled video player, based on a shortcode that contains the You Tube vid...
JQuery configured the textbox collection to the em... How do i go about emptying the values of textboxes here is below code i h've worked out but doesn't seem to work var t...