-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2-starwars_characters.Rmd
executable file
·111 lines (56 loc) · 1.47 KB
/
2-starwars_characters.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
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
---
title: "Star Wars Character Data"
author: "Angela Zoss"
date: "9/7/2018"
output: github_document
---
## Setup your environment
```{r}
# Load required libraries
library(tidyverse)
```
## Load your data
```{r}
# built-in data
starwars_chars <- starwars
```
## Create a plot to explore the height of Star Wars characters
```{r}
# hint: height is numerical;
# look for geoms that do a good job of summarizing numerical variables
```
## Add a facet to the chart to create small multiples for each gender
```{r}
# hint: try facet_wrap
ggplot(starwars_chars) +
geom_histogram(aes(height)) +
facet_wrap(~gender)
```
## Create a new plot to compare character heights to weights (masses)
```{r}
# what geom is best for two numerical variables?
```
## Add a linear trend line
```{r}
# hint: look at the options for geom_smooth
```
## Add a label to (only) the heaviest character
```{r}
# hint: you can use "data=" in a geom layer to use different data for that layer
```
## Add a label to (only) the shortest character
```{r}
```
## Create a new plot to show each character by their age (birth_year)
```{r}
# hint: many characters have NA for birth_year;
# try removing those characters before plotting
```
## Sort the characters by their age
```{r}
# hint: the forcats package (which is included in tidyvers)
# has a useful function called fct_reorder that can be used on factors
```
## Relabel the axes if they are difficult to read
```{r}
```