Chapter 3. Basic Visualization Techniques

In this chapter, we will cover the following recipes:

  • Looking at your data using the plot() function
  • Using pairs.panel() to look at (visualize) correlations between variables
  • Adding text to a ggplot2 plot at a custom location
  • Changing axes appearance to ggplot2 plot
  • Producing a matrix of graphs with ggplot2
  • Drawing a route on a map with ggmap
  • Making use of the igraph package to draw a network
  • Showing communities in a network with the linkcomm package

Introduction

You 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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset