Brett Klamer

Compile Hadley’s ggplot2 Book to a PDF

You will need R, LaTeX, pandoc, and Linux to create the PDF. Please consider purchasing a copy to support his work.

Install R Package Dependencies

# Install CRAN packages
install.packages(c("Lahman", "broom", "mapproj", "wesanderson", "USAboundaries", 
                   "scales", "ggplot2", "ggplot2movies","tidyr", "directlabels", 
                   "ggthemes", "Hmisc", "readr"))

# Install development packages
## Note that the book still uses the old bookdown package Hadley originally
## developed. The new bookdown package is being developed by rstudio/Yihui Xie.
## Since there is currently an issue in the oldbookdown package, You can install
## my fork to get things working.

Install Pandoc Dependencies

# For ubuntu users...
sudo apt-get install pandoc-citeproc

Download the Repository

git clone

File and Directory Fixes

Delete the .tex files in book/tex/ so that everything will be recompiled. Create the empty directories book/tex/_figures and book/tex/diagrams.

Build the book

# Run in terminal at directory root

The resulting pdf was 15.1MB and 283 pages.

Published: 2015-09-08
Last Updated: 2016-03-27