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
Learn about: install ggplot2, ggplot(), qplot().
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
Learn about: histogram, boxplot, density plot, line plot, bar plot, etc.