4 Getting started with graphs

 

This chapter covers

  • An introduction to the ggplot2 package
  • Creating a simple bivariate (2-variable) graph
  • Using grouping and faceting to create multivariate graphs
  • Saving graphs in multiple formats

On many occasions, I’ve presented clients with carefully crafted statistical results in the form of numbers and text, only to have their eyes glaze over while the chirping of crickets permeated the room. Yet those same clients had enthusiastic “Ah-ha!” moments when I presented the same information to them in the form of graphs. Often I can see patterns in data or detect anomalies in data values by looking at graphs—patterns or anomalies that I completely missed when conducting more formal statistical analyses.

Human beings are remarkably adept at discerning relationships from visual representations. A well-crafted graph can help you make meaningful comparisons among thousands of pieces of information, extracting patterns not easily found through other methods. This is one reason why advances in the field of statistical graphics have had such a major impact on data analysis. Data analysts need to look at their data, and this is one area where R shines.

4.1      Creating a graph with ggplot2

 
 

4.1.1   ggplot

 
 

4.1.2   Geoms

 

4.1.3   Grouping

 
 

4.1.4   Scales

 
 

4.1.5   Facets

 

4.1.6   Labels

 
 
 

4.1.7   Themes

 

4.2    ggplot2 details

 
 
 

4.2.1   Placing the data and mapping options

 
 
 

4.2.2   Graphs as objects

 
 

4.2.3   Exporting graphs

 
 
 

4.2.4   Common mistakes

 
 
 

4.3    Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest