Visualizing data with ggplot2

R comes with a built-in functionality for creating graphs and chart. This functionality is often referred to as Base R or R base graphics. In the section 7 of the chapter "Introduction to R", we have seen how to create a simple scatter plot in Base R and how to add or modify the various components of the graph, and in section 8 of the same chapter we have seen which functions may be used to create histograms, pie charts, bar charts and boxplots.

There exist several packages for R which are dedicated to visualization of data. ggplot2 (written by Hadley Wickham) is one of them. In this chapter, we will learn how to build more attractive charts using ggplot2.


Starting with ggplot2
In this first chapter, we learn what ggplot2 is and how we can use it to create plots and charts. We go through the basics of the syntax and the key components of ggplot().

Learn about: install ggplot2,  ggplot(), qplot().


Plot Types

Let's learn to draw some of the most common plot types with ggplot2. Whenever possible, we will see how to write the code using ggplot() and qplot().

Learn about: histogram, boxplot, density plot, line plot, bar plot, etc.


Essential Elements

Set up all the elements necessary to create a proper graph

Learn about: Adding plot title, axis titles, ticks, labels, colors, background, etc.


Multiple Plots/Overlay Plots

Here we will see how to combine two (or more) plots in a single chart

Learn about: multiple histograms, multiple boxplots, combined histogram and density plots, etc.


Faceted Plots

Create multi-panel plots in ggplot2

Learn about: facet_grid() vs. facet_wrap(), etc.