Skip to content

Commit 2f84396

Browse files
committed
Adding workshop files
1 parent 2a4b2c2 commit 2f84396

File tree

98 files changed

+35296
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+35296
-1
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.Rproj.user
2+
.Rhistory
3+
.RData
4+
.Ruserdata

1-got_nyt.Rmd

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
---
2+
title: "Game of Thromes Character Ratings"
3+
author: "Angela Zoss"
4+
date: "9/7/2018"
5+
output: html_document
6+
---
7+
8+
```{r setup, include=FALSE}
9+
knitr::opts_chunk$set(echo = FALSE, message=FALSE)
10+
```
11+
12+
## Setup your environment
13+
14+
```{r}
15+
16+
# Load required libraries
17+
18+
library(tidyverse)
19+
20+
```
21+
22+
## Load your data
23+
24+
```{r}
25+
26+
# data comes from https://int.nyt.com/newsgraphics/2017/2017-07-17-got-matrix/mean.json
27+
# data based on ratings using tool at https://www.nytimes.com/interactive/2017/08/09/upshot/game-of-thrones-chart.html
28+
29+
got <- read_csv("data/got_ratings.csv")
30+
31+
```
32+
33+
## Create a basic plot
34+
35+
```{r}
36+
37+
# a plot should include:
38+
# - a call to ggplot()
39+
# - a dataset
40+
# - a call to aes(), including the main x and y variables
41+
# - a geom layer that specifies the type of chart or shape
42+
43+
```
44+
45+
## Set the size of all points to 5
46+
47+
```{r}
48+
49+
# hint: check ?geom_point to see the different aesthetics options available, but think carefully
50+
# about where the new option should go in the function
51+
52+
53+
```
54+
55+
## Set the alpha (transparency) of all points to .75
56+
57+
```{r}
58+
59+
60+
```
61+
62+
## Add labels
63+
64+
```{r}
65+
66+
# hint: check https://ggplot2.tidyverse.org/reference/#section-layer-geoms for all geom options
67+
68+
69+
70+
```
71+
72+
## Fix label overlap
73+
74+
```{r}
75+
76+
# hint: look at ?geom_text for a property that might change the position slightly
77+
# once you've found something to try, be careful: are you adding a new variable, or is it a constant change?
78+
79+
80+
81+
```
82+
83+
## Add colors
84+
85+
```{r}
86+
87+
# add gender as a color three different ways:
88+
# - points only
89+
# - labels only
90+
# - both
91+
92+
93+
94+
```
95+
96+
## Turn off legend for text layer
97+
98+
```{r}
99+
100+
# hint: there is another property for the geom_text layer that might help
101+
102+
103+
104+
```
105+
106+
107+
## Switch direction of Y axis
108+
109+
```{r}
110+
111+
# hint: edits to axes often use scales
112+
# check https://ggplot2.tidyverse.org/reference/#section-scales for pre-built scales
113+
# that might help (focus on scales for the y-axis)
114+
115+
116+
117+
```
118+
119+
## Add reference lines
120+
121+
```{r}
122+
123+
# hint: there are special geoms for straight lines;
124+
# check https://ggplot2.tidyverse.org/reference/#section-layer-geoms for all geom options
125+
126+
127+
128+
```
129+
130+
```{r}
131+
132+
# look at how ggplot2 is layering the plot; rearrange layers as needed
133+
134+
135+
136+
```
137+
138+
## Change the theme
139+
140+
```{r}
141+
142+
# Try to find a theme closer to the NYT chart;
143+
# see https://ggplot2.tidyverse.org/reference/#section-themes for built-in themes
144+
145+
146+
147+
```
148+
149+
## Change axis limits
150+
151+
```{r}
152+
153+
# the chart might look better if the axes go all the way from 0 to 1; edit
154+
# the axes to force them to include 0 and 1
155+
# hint: remember that changes to axes usually involve a scale
156+
157+
158+
159+
```
160+
161+
## Annotate the axes with descriptive text
162+
163+
```{r}
164+
165+
# hint: geoms are typically best for chart elements involving data;
166+
# look for another feature that can add text to charts
167+
# https://ggplot2.tidyverse.org/reference/
168+
169+
170+
171+
```
172+
173+
## Add a main title
174+
175+
```{r}
176+
177+
# check https://ggplot2.tidyverse.org/reference/ for likely layers
178+
179+
180+
```

0 commit comments

Comments
 (0)