-
Notifications
You must be signed in to change notification settings - Fork 0
/
1-got_nyt.Rmd
executable file
·180 lines (91 loc) · 2.79 KB
/
1-got_nyt.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
---
title: "Game of Thromes Character Ratings"
author: "Angela Zoss"
date: "9/7/2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message=FALSE)
```
## Setup your environment
```{r}
# Load required libraries
library(tidyverse)
```
## Load your data
```{r}
# data comes from https://int.nyt.com/newsgraphics/2017/2017-07-17-got-matrix/mean.json
# data based on ratings using tool at https://www.nytimes.com/interactive/2017/08/09/upshot/game-of-thrones-chart.html
got <- read_csv("data/got_ratings.csv")
```
## Create a basic plot
```{r}
# a plot should include:
# - a call to ggplot()
# - a dataset
# - a call to aes(), including the main x and y variables
# - a geom layer that specifies the type of chart or shape
```
## Set the size of all points to 5
```{r}
# hint: check ?geom_point to see the different aesthetics options available, but think carefully
# about where the new option should go in the function
```
## Set the alpha (transparency) of all points to .75
```{r}
```
## Add labels
```{r}
# hint: check https://ggplot2.tidyverse.org/reference/#section-layer-geoms for all geom options
```
## Fix label overlap
```{r}
# hint: look at ?geom_text for a property that might change the position slightly
# once you've found something to try, be careful: are you adding a new variable, or is it a constant change?
```
## Add colors
```{r}
# add gender as a color three different ways:
# - points only
# - labels only
# - both
```
## Turn off legend for text layer
```{r}
# hint: there is another property for the geom_text layer that might help
```
## Switch direction of Y axis
```{r}
# hint: edits to axes often use scales
# check https://ggplot2.tidyverse.org/reference/#section-scales for pre-built scales
# that might help (focus on scales for the y-axis)
```
## Add reference lines
```{r}
# hint: there are special geoms for straight lines;
# check https://ggplot2.tidyverse.org/reference/#section-layer-geoms for all geom options
```
```{r}
# look at how ggplot2 is layering the plot; rearrange layers as needed
```
## Change the theme
```{r}
# Try to find a theme closer to the NYT chart;
# see https://ggplot2.tidyverse.org/reference/#section-themes for built-in themes
```
## Change axis limits
```{r}
# the chart might look better if the axes go all the way from 0 to 1; edit
# the axes to force them to include 0 and 1
# hint: remember that changes to axes usually involve a scale
```
## Annotate the axes with descriptive text
```{r}
# hint: geoms are typically best for chart elements involving data;
# look for another feature that can add text to charts
# https://ggplot2.tidyverse.org/reference/
```
## Add a main title
```{r}
# check https://ggplot2.tidyverse.org/reference/ for likely layers
```