20100929 ggplot - triangle useRs group presentation

27
ggplot2 Elaine McVey BD Technologies Triangle Area R useRs Group September 29, 2010

description

 

Transcript of 20100929 ggplot - triangle useRs group presentation

Page 1: 20100929 ggplot - triangle useRs group presentation

ggplot2

Elaine McVeyBD Technologies

Triangle Area R useRs Group

September 29, 2010

Page 2: 20100929 ggplot - triangle useRs group presentation

What is ggplot2?

ggplot2 is an R package written by Hadley Wickham that provides a comprehensive framework for statistical graphics based on The Grammar of Graphics (LeLand Wilkinson, 2005)

Page 3: 20100929 ggplot - triangle useRs group presentation

Goal

To show you enough about ggplot2 that you can understand its capabilities, get started using it, and know where to learn more.

Page 4: 20100929 ggplot - triangle useRs group presentation

Benefits

• Since ggplot2 has an underlying conceptual framework, it becomes very powerful once you understand it.

• ggplot2 code is concise and readable• Writing statistical functions (i.e. panel functions) for

ggplot2 is relatively easy.• ggplot2 enforces the link between the data and the

legend, so labeling errors are minimized.• The layering concept makes it easy to combine data

from different dataframes in a single plot.• The active user community provides a good place to get

help and drives ongoing development.

Page 5: 20100929 ggplot - triangle useRs group presentation

Jumping In - Dataframe

Page 6: 20100929 ggplot - triangle useRs group presentation

Jumping In – First Plot

Page 7: 20100929 ggplot - triangle useRs group presentation

Layers

Page 8: 20100929 ggplot - triangle useRs group presentation

More Layers - oops

Page 9: 20100929 ggplot - triangle useRs group presentation

More Layers - corrected

Page 10: 20100929 ggplot - triangle useRs group presentation

Non-Mapped Attributes

Page 11: 20100929 ggplot - triangle useRs group presentation

Accidental Aesthetic Mapping

Page 12: 20100929 ggplot - triangle useRs group presentation

Aesthetic Mapping by geom

Page 13: 20100929 ggplot - triangle useRs group presentation

Bigger Dataframe

Page 14: 20100929 ggplot - triangle useRs group presentation

Facets and Colors

Page 15: 20100929 ggplot - triangle useRs group presentation

Statistical Summaries

Page 16: 20100929 ggplot - triangle useRs group presentation

Creating errBars

Page 17: 20100929 ggplot - triangle useRs group presentation

Lattice Comparison

Page 18: 20100929 ggplot - triangle useRs group presentation

Expanding errBars

Page 19: 20100929 ggplot - triangle useRs group presentation

Layering Dataframes

plyr aside:

Page 20: 20100929 ggplot - triangle useRs group presentation

Layering Dataframes in geoms

Page 21: 20100929 ggplot - triangle useRs group presentation

Updating Plots

Page 22: 20100929 ggplot - triangle useRs group presentation

Where to go next

1) ggplot2: Elegant Graphics for Data Analysis(skip qplot)

2) had.co.nz/ggplot2 (& plyr & reshape . . . )

3) Google group listserv

Page 23: 20100929 ggplot - triangle useRs group presentation
Page 24: 20100929 ggplot - triangle useRs group presentation
Page 25: 20100929 ggplot - triangle useRs group presentation
Page 26: 20100929 ggplot - triangle useRs group presentation

Def

ault

stat

istic

s an

d ae

sthe

tics

for

each

geo

m

Page 27: 20100929 ggplot - triangle useRs group presentation