In this chapter, we will cover the following recipes:
plot()
functionpairs.panel()
to look at (visualize) correlations between variablesggplot2
plot at a custom locationggplot2
plotggplot2
ggmap
igraph
package to draw a networklinkcomm
packageYou now have your data in R (as discussed in Chapter 1, Acquiring Data for Your Project) and you gained a good understanding of its structure (in Chapter 2, Preparing for Analysis – Data Cleansing and Manipulation), but do you have an idea of its, let's say, appearance?
Do you know how data is related to itself? Do any correlations exist?
If you want to model your phenomenon with accuracy and effectiveness, you have to know the answers to these questions. This is where basic data visualization comes in handy. This includes plotting your variables against one another, looking for correlations, understanding relations (or absence of relations) without losing yourself in hundreds of lines of code.
In this chapter, we will do all of this mainly using base R and ggplot2
, which is the data visualization package that lets you produce plots by applying the grammar of graphics and has become a standard of R dataviz.
Besides basic data visualizations recipes, some goodies are also provided in this chapter, such as the recipe that lets you place text at a custom location on your ggplot
or the one about axis manipulation with ggplot2
.
These recipes are provided here to let you get sufficient control over your plots and make them a sound basis for the next data analysis activities.