ABSTRACT

This chapter discusses the lattice and the ggplot2 packages that are well-suited for constructing more sophisticated graphical displays. It focuses on the use of these packages for baseball data. The lattice graphics system, written by Deepayan Sarkar, provides an R implementation of Trellis displays, a regular gridlike framework for visualizing multivariate data, popularized by William Cleveland. The lattice package is currently included with the R base distribution and it becomes available for use by loading with the library function. One of the main enhancements of the lattice package over the traditional graphics package is that it allows multipanel conditioning. Multipanel conditioning plots and superposed plots can be constructed using a variety of graphical methods in the lattice package. Graphics in ggplot2 are constructed by progressively adding layers, starting with the raw data, then adding strata of statistical summaries and annotations.