-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvizdata_ggplot2_examples.Rmd
More file actions
42 lines (27 loc) · 1.16 KB
/
vizdata_ggplot2_examples.Rmd
File metadata and controls
42 lines (27 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
R Examples from Visualizing Data by William Cleveland
=====================================================
GGplot2 graphics examples from [Visualizing Data](http://www.stat.purdue.edu/~wsc/visualizing.html) [Amazon](http://www.amazon.com/Visualizing-Data-William-S-Cleveland/dp/0963488406) by William Cleveland.
Based on Splus data from http://www.ats.ucla.edu/stat/examples/vizdata/ and R code from
[Graph Examples from Visualizing Data by William Cleveland](http://www.wekaleamstudios.co.uk/posts/graph-examples-from-visualizing-data-by-william-cleveland/)
```{r setup}
# Read the data
load("visualizing_data.Rdata")
# Use Ggplot2 graphics
library(ggplot2)
```
```{r chapter1}
# Figure 1.1
# Figure 1.2
qplot(height, data = singer, xlab = "Height (inches)") +
geom_histogram() + facet_wrap( ~ voice.part, ncol = 2)
# Figure 1.3
# Figure 1.4
qplot(E, NOx, data = ethanol, xlab = "E",
ylab= "Oxides of Nitrogenn(micrograms/J)")
# Figure 1.5
qplot(C, NOx, data = ethanol, xlab = "C",
ylab= "Oxides of Nitrogenn(micrograms/J)")
# Figure 1.6
qplot(yield, variety, data = barley, xlab = "Barley Yield (bushels/acre)") +
geom_point() + facet_grid(site ~ year)
```