The Working R Programmer

Tips and tricks for serious software development in R

Purpose of this blog

Since I already have a blog, you might be asking, “why another one?”.

It’s a fair question, and I am not creating a new blog just to make you follow two instead of one. Except for these “start-up posts”, where I am simply experimenting with the new blogging software, I plan to combine posts on this blog with posts on the other, linking here. So, you should be able to get all the posts here by following the blog over there. Since I haven’t figured out how to have comments here—and I suspect it isn’t possible since Hugo is a static page system—the other blog is the place for that, I guess.

Of course, if you are only interested in R programming, and not whatever else might be going on in my life, then this would be the blog to follow. You can then safely ignore the other—if there are any R topics I want to write about, they will go here.

Okay, so back to the question—”Why another blog for R?”

It is not that I feel passionately about segmenting blogging topics into separate blogs; the answer is much simpler than that. I cannot figure out how to display R code consistently on Wordpress.

I have various plugins for syntax highlighting, and they do work, of a sorts, but the markup needed to display source code differs between them and half of them get < and > wrong and treat code involving comparisons as malformed HTML. It is a pain to work with these plugins.

I have now written five and a half books about R programming. For those books, obviously, I have had to present well-formatted and syntax highlighted code. For that, I have used a combination of knitr and Markdown + Pandoc.

Writing in Markdown is pleasant. There are very simple markups that usually handle all your needs, and unlike (La)TeX, they don’t get in the way of the text flow. More importantly, when writing about programming, there is markups for displaying highlighted source code. Like this:

f <- function(x) exp(x^2)

Combined with knitr, you can even get such code evaluated when formatting a Markdown file.

f <- function(x) exp(x^2)
## [1] 54.59815

So, having suffered enough frustration with formatting R code on Wordpress, I am ready for some frustration from using knitr and Hugo.

On top of that frustration list are:

  1. The base URL isn’t set correctly for knitr plot output, and
  2. The tags and category links point to 404 although the directories and files they should point to are there.

If you know anything about Hugo and knitr/blogdown, I could really use your help. A pull request on GitHub would be amazing—and I have one or two curtesy copies of Functional Data Structures I might reward substantial help with.

Post-publication edit: Ok, the problems with tags and categories seems to only appear on my local machine. On GitHub it seems to be working.