440

# QCBS R workshop - Visualization

March 22, 2013

## Transcript

1. ### Plotting in Open Source Statistical Programming map courtesy of James

Cheshire (spatialanalysis.co.uk/2012/02/great-maps-ggplot2/)
2. ### Tables Data Graphs Statistics Understanding Sigmaplot Excel SAS Why do

your plotting in R? Simpler workflow:
3. ### Tables Data Statistics Understanding Graphs Why do your plotting in

R? Simpler workflow:

8. ### * Challenge 1: Building a plot layer by layer 1.

Use the 'iris' dataset to build the following three plots: a. A plot of Sepal.Length vs. Sepal.Width b. The same plot, but coloured by 'Species' c. A plot of Petal.Length vs. Species
9. ### * Challenge 2: Playing with aesthetics and geoms 1. Use

the qplot function and the 'iris' dataset to re- build the following three plots: a. A plot of Sepal.Length vs. Sepal.Width b. The same plot, but coloured by 'Species' c. A plot of Petal.Length vs. Species 2. For the plot in part 'c', try changing the geom argument to "boxplot". Try building a graph with both points and boxplot on them
10. ### * Challenge 3: Faceting and scaling 1. Try to build

the following plots using the iris data: a. Petal.Width vs. Petal.Height, faceted in a row by Species; and the same plot by column b. Sepal.Width vs. Sepal.Height, with the x-axis log-transformed, the y-axis log-transformed, and both axes log-transformed
11. ### ggplot2: using the Grammar of Graphics ggplot2: a different way

of plotting: building plots by describing what you want, and let it figure out how to plot it.
12. ### ggplot2: using the Grammar of Graphics ggplot2: Builds plots out

of simpler components: • data • aesthetics: e.g. coordinates, colour, size of points • geoms: the type of plot layer: line, point, etc. • facets: organizing graphs into subplots • transforms: logs, square roots, continuous to discrete etc. • stats: functions of the raw data • coordinates: e.g. Euclidean, map coords, polar • themes: font size, grids, etc.
13. ### Further reading Plotting in general: R Graphics The R Book

ggplot2 references: The creator, Hadley Wickham's website The in-depth documentation website The book: ggplot2: Elegant Graphics for Data Analysis