I am unable to compile PDF using RMarkdown, the waffle package, and glyphs
It doesn't matter if I use the TIKZ device or PDF rendering. The document compiles without a problem to HTML.
The only work around I can think of right now is to create SVG graphic with the HTML compiler, then to reference those files in my intermediate .TEX file.
Notice that if you simply run the code below the line that says, " ## ---- waffle_figure ---- ". It should create the chart given that you've previously installed the fontawesome font on your system, installed the extrafont package in R, and run the font_install() command.
---
title: "Waffle"
output:
pdf_document:
latex_engine: xelatex
html_document: default
header-includes:
- \usepackage{fontspec}
- \defaultfontfeatures{Extension = .otf}
- \usepackage{fontawesome}
- \usepackage{tikz}
---
```{r setup, include=FALSE}
library(knitr)
library(tikzDevice)
knitr::opts_chunk$set(warning = FALSE, error = FALSE, message = FALSE, results='hide', echo = FALSE, dev = "tikz", external = TRUE)
```
\faTwitter
## Waffle Plot
You can also embed plots, for example: \newline
```{r pressure, echo=FALSE, dev="tikz"}
## ---- waffle_figure ----
loadpackages <- function(package.list = c("ggplot2", "Rcpp")) {
new.packages <- package.list[!(package.list %in% installed.packages()[,"Package"])]
if (length(new.packages)){install.packages(new.packages, repos = 'http://cran.us.r-project.org')}
lapply(eval(package.list), require, character.only = TRUE)}
loadpackages(c("waffle", "extrafont", "grid", "gridExtra", "tikzDevice"))
parts <- c(40, 30, 20, 10)
waffle(parts,
rows=10,
use_glyph = "user",
glyph_size = 5)
```