What this book covers

Chapter 1, R Graphics, introduces the reader to the R graphic system, how R graphs work with default libraries, and also to the very recent revolution of lattice and ggplot2. Here, readers will get a flavor of what is going to be discussed in the subsequent chapters.

Chapter 2, Basic Graph Functions, introduces recipes for some basic types of graphs, useful in almost any kind of data analysis. We will go through all the steps to get you going from reading your data into R, making a first graph, tweaking it to suit your needs, and then saving and exporting it for use in presentations and publications.

Chapter 3, Beyond the Basics – Adjusting Key Parameters, looks more closely at various arguments to graph functions and their values, highlighting common pitfalls and workarounds. The par() function is explained with some useful examples, showing how to adjust colors, sizes, margins, and the styles of various graph elements such as points, lines, bars, axes, and titles. The subsequent chapters 3 to 9 cover the graph types introduced in the first two chapters in more detail.

Chapter 4, Creating Scatter Plots, has over a dozen recipes that cover scatter plots, some of the simplest and most commonly used types of graphs in data analysis. We will see how we can make more enhanced plots by adjusting various arguments and using some new functions.

Chapter 5, Creating Line Graphs and Time Series Charts, discusses some more intermediate to advanced recipes on customizing line graphs, improving and speeding up line graphs with multiple lines, processing dates to make time series charts, sparklines, and stock charts.

Chapter 6, Creating Bar, Dot, and Pie Charts, will show you how you can create many useful variations of bar graphs and dot plots by using only the base library functions. We will also look at a few recipes that address common criticisms of pie charts with some ways to make them more readable.

Chapter 7, Creating Histograms, enhances the basic histogram in R by changing the plotting mode and bins, in addition to style adjustments. We will also look at some advanced recipes that combine histograms with other types of graphs.

Chapter 8, Box and Whisker Plots, looks into various stylistic and structural adjustments to box plots. We will start by looking at some basic arguments to change individual aspects of a box plot and slowly move to more advanced recipes that involve the use of multiple function calls.

Chapter 9, Creating Heat Maps and Contour Plots, discusses various types of heat maps to visualize correlations, trends and multivariate data, and contour plots to show topographical information in various two- and three-dimensional ways.

Chapter 10, Creating Maps, builds on the introduction to visualizing data on geographical maps in the first chapter and covers recipes on plotting data from the World Bank, World Health Organization (WHO), Google Maps API, and some Geographical Information Systems (GIS).

Chapter 11, Data Visualization Using Lattice, contains various recipes to create the most common graphs using the lattice library. Lattice is one of the most popular data visualization libraries in R. This chapter contains 9 different recipes ranging from bar charts to distributional plots and empirical cumulative distribution.

Chapter 12, Data Visualization Using ggplot2, contains how we can create very high-quality data visualization using the concept of Grammar of Graphics. There are 8 different recipes to create the most common graphics. This chapter contains 1 special recipe where we discuss how to annotate a graph. The annotated graph contains an enormous amount of information. The recipe ranges from very basic graphics to advanced ones, where we show how we can incorporate layered graphs, such as a scatter plot embedded with the lowest and least square-fitted lines.

Chapter 13, Inspecting Large Datasets, contains recipes related to one of the newest concepts of finding patterns in large data through visualization. The recipes of this chapter show how to create nice graphs that tell us a story about the pattern of relationship among variables.

Chapter 14, Three-dimensional Visualizations, has most of its recipes centered on creating three-dimensional graphics ranging from scatter plots to density estimations. In this chapter, we also include how to create three-dimensional scatter plots with an estimated linear plane.

Chapter 15, Finalizing Graphs for Publications and Presentations, discusses some tricks and tips to add some polish to our graphs so that they can be used for publication and presentation. We will cover many important practical topics such as exported graph file formats, high resolution formats, vector formats such as PDF, SVG, and PS, mathematical and scientific notations, text descriptions, fonts, graph templates, and themes.