Getting started

To profit best from this course, you need to install both R and R Studio on your computer. See the install tutorial for further details.

Session 1: Overview

Topics:

  • Getting started: R, R Studio
  • The roles of graphics in data analysis (exploration, analysis, presentation)
  • What can I do with R graphics: Anything!
  • R graphics systems: base graphics; grid graphics; ggplot2
  • Reproducible analysis and reporting with knitr and R markdown with R Studio

R scripts:

Session 2: Standard graphics in R

Topics:

  • R has a simple, object-oriented design that facilitates data analysis and plots.
  • Much of what you need or want to do can be done with this, by simply using plot(object).
  • Tweaking graphs: Learn to control the details of R graphs by controling the graphic parameters: color, point symbols, line styles and so forth.
  • Annotating graphs: Graphs for different purposes can be enhanced by adding features, such as fitted lines, confidence envelopes, data ellipses, or text

R scripts:

Session 3: Grid and lattice graphics

This session is not being taught this year. The lecture notes and examples are available online.

- Lecture notes: 1up PDF; 4up PDF

Topics:

  • The grid graphics system for R provides an alternative and more powerful means to construct data graphics in R.
  • The lattice package provides functions for drawing all standard plots (scatterplots, histograms, density plots, etc.), usually with more pleasing default results, but more importantly, allows you to compose collections (“small multiples”) of simpler graphs from structured subsets of the data.
  • The vcd package uses grid graphics to produce a wide variety of plots for categorical data (mosaic plots, spine plots, sieve diagrams, etc.)

R scripts:

Session 4: ggplot2

Topics:

  • ggplot2 takes a totally different, but arguably most powerful, approach to the construction of statistical graphs, based on the “Grammar of Graphics”.
  • The graphic language of ggplot2 makes it easier to think of a graph as composed of layers (points, lines, regions), each of which is rendered with various graphical attributes.
  • ggplot2 is part of a workflow for “tidy” data manipulation and graphics that is well worth learning.

R scripts: