forked from core-methods-in-edm/class-activity-3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
class-activity-3.Rmd
67 lines (52 loc) · 1.37 KB
/
class-activity-3.Rmd
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
---
title: "class activity 3"
author: "Charles Lang"
date: "10/2/2018"
output: html_document
---
#Mapping aesthetic to data to = layer
```{r}
install.packages("ggplot2")
library(ggplot2)
ggplot(diamonds, aes(x = price, y = carat)) +
geom_point()
```
#Two layers
```{r}
ggplot(mpg, aes(reorder(class, hwy), hwy)) +
geom_jitter() +
geom_boxplot()
```
```{r}
#Plot count
ggplot(diamonds, aes(depth)) +
geom_histogram(aes(y = ..count..), binwidth=0.2) +
facet_wrap(~ cut) + xlim(50, 70)
#Plot density
ggplot(diamonds, aes(depth)) +
geom_histogram(aes(y = ..density..), binwidth=0.2) +
facet_wrap(~ cut) + xlim(50, 70)
```
```{r}
ggplot(mpg, aes(displ, hwy, color = class)) +
geom_point()
```
Can you create a line graph using the "economics_long" data set that shows change over time in "value01" for different categories of "variable"?
```{r}
```
If you would like to recreate the Minard graphic of Napoleon's Troops the code is below and the data is in this repo.
```{r}
ggplot(cities, aes(long, lat)) +
geom_path(aes(size = survivors, colour =
direction,
group = interaction(group, direction)), data =
troops) +
geom_text(aes(label = city), hjust = 0, vjust = 1,
size = 4)
# Polish appearance
last_plot() +
scale_x_continuous("", limits = c(24, 39)) +
scale_y_continuous("") +
scale_colour_manual(values = c("grey50","red")) +
scale_size(to = c(1, 10))
```