0.2 Software and Platform Notes
Most of the recipes here use the ggplot2 plotting package, and the dplyr package for data wrangling. These packages are both part of the tidyverse, which is a collection of R packages that make it easier to work with data. Some of the recipes require the most recent version of ggplot2, 3.0.0, and this in turn requires a relatively recent version of R. You can always get the latest version of R from the main R project site, http://www.r-project.org.
You can use the recipes with just a surface understanding of ggplot2, but if you want a deeper understanding of how it works, see Chapter A.
Once you’ve installed R, you can install the necessary packages. In addition to the tidverse packages, you’ll also want to install the gcookbook package, which contains data sets for many of the examples in this book. You can install the tidyverse packages and the gcookbook package with:
You may be asked to choose a mirror site for CRAN, the Comprehensive R Archive Network. Any of the sites should work, but it’s a good idea to choose one close to you because it will likely be faster than one far away. Once you’ve installed the packages, load the ggplot2 and dplyr packages in each R session in which you want to use the recipes in this book:
The recipes in this book will assume that you’ve already loaded ggplot2 and dplyr, so they won’t show these lines of code.
If you see an error like this, it means that you forgot to load ggplot2:
Error: could not find function "ggplot"
The major platforms for R are macOS, Linux, and Windows, and all the recipes in this book should work on all of these platforms. There are some platform-specific differences when it comes to creating bitmap output files, and these differences are covered in Chapter 14.