Bonus Chapter 23. Advanced graphics with the lattice package

 

This chapter covers

  • An introduction to the lattice package
  • Grouping and conditioning
  • Adding information with panel functions
  • Customizing a lattice graph’s appearance

In this book, you created a wide variety of graphs using base functions from the graphics package included with R and specialized functions from author-contributed packages. In chapter 19, you learned a new syntax for creating graphs using functions from the ggplot2 package. The ggplot2 package offers an alternative to R’s base graphics and is particularly useful when creating complex plots.

In this bonus chapter, we’ll look at the lattice package, written by Deepayan Sarkar (2008); this package implements trellis graphics as outlined by Cleveland (1985, 1993). The lattice package has grown beyond Cleveland’s original approach to visualizing data and now provides a comprehensive system for creating statistical graphics. Like ggplot2, lattice graphics has its own syntax, offers an alternative to the base graphics, and excels at plotting complex data. Analysts tend to use either lattice or ggplot2, based on personal preference. Try them both and see which one you prefer.

23.1. The lattice package

The lattice package provides a comprehensive graphical system for visualizing univariate and multivariate data. In particular, many users turn to the lattice package because of its ability to easily generate trellis graphs.

23.2. Conditioning variables

23.3. Panel functions

23.4. Grouping variables

23.5. Graphic parameters

23.6. Customizing plot strips

23.7. Page arrangement

23.8. Going further