12
GRAPHICS
R has a very rich set of graphics facilities.
The R home page (http://www.r-project
.org/) has a few colorful examples, but to
really appreciate R’s graphical power, browse
through the R Graph Gallery athttp://addictedtor.free
.fr/graphiques.
In this chapter, we cover the basics of using R’s base, or traditional,
graphics package. This will give you enough foundation to start working
with graphics in R. If you’re interested in pursuing R graphics further, you
may want to refer to the excellent books on the subject.^1
12.1 Creating Graphs...........................................................
To begin, we’ll look at the foundational function for creating graphs:plot().
Then we’ll explore how to build a graph, from adding lines and points to
attaching a legend.
(^1) These include Hadley Wickham,ggplot2: Elegant Graphics for Data Analysis(New York: Springer-
Verlag, 2009); Dianne Cook and Deborah F. Swayne,Interactive and Dynamic Graphics for Data
Analysis: With R and GGobi(New York: Springer-Verlag, 2007); Deepayan Sarkar,Lattice: Multi-
variate Data Visualization with R(New York: Springer-Verlag, 2008); and Paul Murrell,R Graphics
(Boca Raton, FL: Chapman and Hall/CRC, 2011).