Advanced graphing
Now is the time when we head towards the final section of this chapter. This section is a bit lighter. We will finish the chapter and the book with additional visualizations of the data. This section discusses advanced graphing with the help of the ggplot2
package.
This section introduces the following:
- Basic
ggplot()
function - Advanced plot types
- Trellis charts
Introducing ggplot2
The ggplot2
package is a frequently used graphical package among the R community. The package provides comprehensive and coherent grammar for graphical functions. The grammar is also consistent, and you can create nice graphs with this package. The ggplot2
package enhances the built-in graphical capabilities and gives a layer-oriented approach to plotting graphs.
The following command installs the package and loads it to memory:
install.packages("ggplot2"); library("ggplot2");
Here is the code for the first graph that uses the ggplot()
function. The data used is the TM data frame...