What this book covers
Chapter 1, Graphics in R, gets you up and running with R and ggplot2 by providing you with a description of the R installation as well as the integrated development environment you may want to use in your daily use of R. You will also be introduced to the general ideas behind the different packages available for data visualization, graphics and lattice, and you will also see a few examples of how different plots realized with these packages can be realized with ggplot2. This will provide you with a quick reference to the similarities and differences among the different versions of code if you are already familiar with the other packages.
Chapter 2, Getting Started, provides you with an easy start to ggplot2 and the different plots that can be realized. We will see different plot examples using the qplot (quick plot) function, which provides you with a simplified tool to easily generate plots. In this chapter, we will go through histograms, density plots, bar charts, boxplots, scatterplots, time series, and dot charts.
Chapter 3, The Layers and Grammar of Graphics, gives you a general introduction to the different components on which the grammar of graphics is based. Such components are, for instance, the scales, coordinate system, faceting, aesthetic, and geometry. Understanding these is crucial for the use of the full potential of this package since only understanding the layered grammar can provide you with the right overview of how the different components are connected to each other. In this chapter, you will also find a series of tables summarizing the options available for function arguments, such as geometry and statistics, and they are intended to provide you with a reference for consultation when needed.
Chapter 4, Advanced Plotting Techniques, presents a few more advanced features and plots that can be realized in ggplot2. Building on the knowledge you will have developed, we will see how the grammar components can be combined to generate more complex plots. You will see how more advanced aesthetic mapping can be realized, for instance, using variables generated from statistical analysis or how components such as text and reference lines can be included on a plot. We will then also see how polar coordinate systems can be used to generate pie charts and other types of plots.
Chapter 5, Controlling Plot Details, shows you how you can modify the plot details as well as the default plot layout. You will see how we can modify the plot title, axis, and legend appearance and position. Moreover, you will also see how themes can be used to completely customize the plot appearance without affecting the data represented.
Chapter 6, Plot Output, shows you how to modify and organize multiple plots after their realization. We will see how to reproduce multiple plots next to each other and save the plots in different file formats from the R console, as well as using scripting commands.
Chapter 7, Special Applications of ggplot2, shows you examples of the special application of ggplot2 and other packages based on ggplot2. We will see how we can include maps in plots as well as add data to such maps; we will see how we can draw scatterplot matrices to represent the relationships between different variables. Finally, we will see how we can realize heat maps.