R Graphs Cookbook Second Edition
上QQ阅读APP看书,第一时间看更新

Chapter 1. R Graphics

R provides a number of well-known facilities that produce a variety of graphs to meaningfully visualize data. It has low-level facilities where we deal with basic shapes to draw graphs and high-level facilities. There are functions available here to produce quality graphs; these functionalities are usually developed using certain combinations of basic shapes. Using R, we can produce traditional plots, the trellis plot, and very high-level graphs inspired by the Grammar of Graphics implemented in the ggplot2 package. The default graphics package is useful for traditional plots, lattice provides facilities to produce trellis graphs, and the ggplot2 package is the most powerful high-level graphical tool in R. Other than these, there are low-level facilities that draw basic shapes, and arranging the shapes in their relative position is an important step in order to create meaningful data visualization. In this chapter, we will introduce both low-level graphics (also known as base graphics) and high-level graphics using different packages. Particularly, the content of this chapter will be as follows:

  • Base graphics using the default package
  • Trellis graphs using lattice
  • Graphs inspired by Grammar of Graphics