# Failure to produce pdf with RMarkdown tidyverse

I’m using tidyverse for everything now, as I’ve mentioned in previous posts, when I want a cup of tea I just run:


house %>%
filter(kitchen == 1) %>%
select(tea, kettle) %>%
infuse()



I just ran the following code in a vanilla RStudio setup with pdflatex installed:


---
title: "Test document"
author: "Chris Beeley"
date: "20 December 2017"
output: pdf_document
---

{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)  {r} library(tidyverse) # let's do some data stuff here...   This is the code that you get if you set up an RMarkdown project in RStudio and select “compile to LaTeX”, and you want to do some data stuff with the tidyverse package. And it produced the following error message: ! Package inputenc Error: Unicode char √ (U+221A) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H for immediate help. l.145 \end{verbatim} Try running pandoc with –latex-engine=xelatex. pandoc: Error producing PDF Error: pandoc document conversion failed with error 43 Execution halted I was a bit confused by this for quite a while, the answer of course turns out to be the lovely messages which the tidyverse produces on loading: With the default message = TRUE behaviour in the code chunk pandoc ends up trying to render those little ticks in LaTeX. Evidently it doesn’t support unicode. So the document fails, and it’s hard to understand why until you knit to HTML and see the little ticks. Changing the knitr::opts_chunk$set(echo = TRUE) line to knitr::opts_chunk\$set(echo = TRUE, message = FALSE) fixes the problem.

I can’t help but think that this is a rare example of R getting harder to use. When I started with R 10 years ago it was much more difficult to do even simple things like load a csv file or work with dates. These days there are lots of lovely packages to help, and of course RStudio itself makes using R much more intuitive. But this is going to confuse newbies, I think, which is a bit of a shame.

There are several obvious fixes, I won’t bother to list them all, maybe make message = FALSE the default in RMarkdown documents in RStudio seems like the best one, but maybe there’s some reason they don’t want to do that.

# Font size of code in .Rpres presentations

I don’t know if I even knew about the .Rpres presentation feature in RStudio v. 0.98 and above. As I think I mentioned I’ve been rather ill for the last couple of years and I’m afraid I kind of fell out of touch with things a bit. Anyway, I’m all better now and I’m going to be giving a talk at the R User Group in Nottingham (which I love profoundly) so I thought I’d do it this new sexy way.

It seems pretty handy, haven’t made the whole presentation yet so I’m sure there’s more to come but the first thing is, dang! The code in an echo = TRUE chunk is really large! I can’t fit any output on the page!

So I found this guide to making it smaller, and lots of other nice tweaks, too.