pandoc document conversion failed with error 43

Today I had a “pandoc document conversion failed with error 43” error when compiling a document in Rstudio and directly with rmarkdown. Such an error used to occur a couple of years ago, but that bug has long been fixed. At first I was a bit puzzled, given that this was a rather simple document. It turned out that this error can be a sign of a poorly specified ‘date’ argument in the header, more specifically pandoc does not like a period there.

So
---
title: "Something"
author: "Didier Ruedin"
date: "7 March 2017"
output: pdf_document
---

works, while

---
title: "Something"
author: "Didier Ruedin"
date: "7. March 2017"
output: pdf_document
---

does not. In German, typically there is a period in dates, like 7. März 2017.

Combining Three Date Variables in R

A few months ago I worked with a data set that had three separate variables to capture a date: Year, month, day. This isn’t very practical, and I was looking into a way to combine these in R. It’s not hard, all that’s needed is the paste and as.Date functions:

as.Date(paste(year, month, day, sep='-'))

paste combines the variables, and I specify the separator to be simple dashes, giving dates in the form “2013-11-24” (apparently ISO 8601). That’s the first form the function checks; no need to complicate things here. as.Date turns this into a Date object so that the variable behaves as expected. Yes, there is a capital “D” here.