There are three main options for visualizing data with R. These options are not mutually exclusive, but it’s useful to understand the basics of each.
Base R comes with some basic plotting capabilties. It is useful for quickly visualizing data, but seldom produces visualizations that you would want to include in a final deliverable due to the lack of formatting and control available.
The ggplot2
package is the de facto standard visualization package. It was developed by Hadley Wickham and is based on the “grammar of graphics,” which was an academic exercise conducted some time back that looked to break down all of the possible components of a data visualization into component parts. The idea was that, if such an exercise resulted in a finite number of components, then those components could be assembled in a nearly infinite number of ways.
As it turns out…this works!
But, it can be confusing.
ggplot
also has a concept of “themes.” These are extraordinarily useful. If you’ve ever worked with CSS for HTML or with styles in Microsoft Word (or, to a lesser extent, in Google Docs), then you will get themes pretty easily. They cascade/inherit – just like CSS – so you can define a base theme and then selectively override any aspects you need to for a specific visualization.
For visualizations that fall outside the bounds of ggplot2 (although some of them actually rely on ggplot2 under the hood), there are packages that get developed for a specific type of visualization. A few examples of such packages are:
VennDiagram
– as you might expect…it’s a package for rendering Venn diagramswordcloud
– a package for rendering wordclouds almost as powerful as Wordlecorrgram
– a package for rendering a grid of correlation plots with options to display the data within each cell as a small scatterplot, as a small piechart, or simply color coded