-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualization-presentation.Rpres
More file actions
129 lines (82 loc) · 2.88 KB
/
visualization-presentation.Rpres
File metadata and controls
129 lines (82 loc) · 2.88 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Introduction to data visualization
========================================================
author: John M. Drake & Ana I. Bento
date:
autosize: true
Why this workshop?
========================================================
"Coding is a basic science skill"
- Dr. James Olds, Assistant Director for Biological Sciences, National Science Foundation
Overview
========================================================
- Data visualization
- Writing computer programs
- Data wrangling
- Modeling
- Project management
R/RStudio
========================================================

***
<http://www.r-project.org/>
Why look at data?
========================================================

How to look at data?
========================================================
- Scatterplot
- Box-and-whisker diagram
- Barplot
- Map
- Network
A grammar of graphics
========================================================
Grammar - The fundamental principles or rules of an art or science
- OED, quoted in Wickham (2010)
***

A plot
========================================================
Consists of
- A dataset and mappings from *variables* to *aesthetics*
- One or more *layers*
- A *scale* for each mapping
- A *coordinate system*
- A *facet specification* (usually for multi-panel plots)
A layer
========================================================
Consists of
- Data and aethetic mapping
- A statistical transformation
- A geometric object
- Position adjustment
***

A graphing template
========================================================
`ggplot(data=<DATA>) + <GEOM_FUNCTION>(mapping=aes(<MAPPINGS>))`
```{r, fig.width=6, fig.height=4}
library(ggplot2)
ggplot(data=diamonds) +
geom_bar(mapping=aes(x=cut, fill=clarity))
```
Aesthetics
========================================================
An *aesthetic* is a visual property attached to some data in a plot, e.g.
* Size
* Shape
* Color
```{r, fig.width=6, fig.height=4, echo=FALSE}
library(ggplot2)
ggplot(data=diamonds) +
geom_bar(mapping=aes(x=cut, fill=clarity))
```
Exercises
========================================================
**Notes**
- This workshop addresses visualization, programming, and data wrangling separately, but they're inevitably intertwined. You will have to do some data wranging (e.g. with the package `lubridate`) and minor programming (e.g. assignment operation) to complete this exercise. This may be frustrating. **Stick with it -- it's worth it!**
- A good strategy: Find an example -> Modify -> Compute. Repeat.
- Google is very helpful (especially **Stack Overflow** and **Cross Validated**)
References
========================================================
Wickham, H. 2010. A layered grammar of graphics. *Journal of Computational and Graphical Statistics* 19:3–28