-
Notifications
You must be signed in to change notification settings - Fork 0
/
slides_tidyverse.html
419 lines (405 loc) · 23.8 KB
/
slides_tidyverse.html
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
<!DOCTYPE html>
<html>
<head>
<title>Tidyverse</title>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="slides_tidyverse_files\rmdshower/node_modules/shower-ribbon/styles/screen-4x3.css">
<link rel="stylesheet" href="slides_tidyverse_files\rmdshower/style-common.css">
<link rel="stylesheet" href="slides_tidyverse_files\rmdshower/style-ribbon.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.js"></script>
<script src="slides_tidyverse_files\rmdshower/auto-render.min.js" type="text/javascript"></script>
<style type="text/css">
div.sourceCode { overflow-x: auto; }
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; line-height: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
code > span.dt { color: #902000; } /* DataType */
code > span.dv { color: #40a070; } /* DecVal */
code > span.bn { color: #40a070; } /* BaseN */
code > span.fl { color: #40a070; } /* Float */
code > span.ch { color: #4070a0; } /* Char */
code > span.st { color: #4070a0; } /* String */
code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
code > span.ot { color: #007020; } /* Other */
code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
code > span.fu { color: #06287e; } /* Function */
code > span.er { color: #ff0000; font-weight: bold; } /* Error */
code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
code > span.cn { color: #880000; } /* Constant */
code > span.sc { color: #4070a0; } /* SpecialChar */
code > span.vs { color: #4070a0; } /* VerbatimString */
code > span.ss { color: #bb6688; } /* SpecialString */
code > span.im { } /* Import */
code > span.va { color: #19177c; } /* Variable */
code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code > span.op { color: #666666; } /* Operator */
code > span.bu { } /* BuiltIn */
code > span.ex { } /* Extension */
code > span.pp { color: #bc7a00; } /* Preprocessor */
code > span.at { color: #7d9029; } /* Attribute */
code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
</style>
</head>
<body class="shower list">
<header class="caption">
<h1>Tidyverse</h1>
<p>Ranae Dietzel</p>
</header>
<section id="tidyverse" class="slide level2">
<h2>Tidyverse</h2>
<ul>
<li>A place where people and their mental well-being are valued.<br />
</li>
<li>Welcoming to non-programmers.<br />
</li>
<li>Seeks to be a utopia of data science.<br />
</li>
<li>One of many R universes. My favorite.</li>
</ul>
</section>
<section id="philosophy-best-explained-by-creator" class="slide level2">
<h2>Philosophy best explained by creator</h2>
<p>Hadley Wickham’s talk from UseR! 2016 <a href="https://channel9.msdn.com/Events/useR-international-R-User-conference/useR2016/Towards-a-grammar-of-interactive-graphics">Tools for tidy data</a></p>
<p><font size="22">If someone is making a “pit of success”, you should probably walk towards it.</font></p>
</section>
<section id="best-way-to-learn-the-tidyverse" class="slide level2">
<h2>Best way to learn the tidyverse</h2>
<center>
<img src="images/r4ds_cover.jpg" width="300px" />
</center>
<p><a href="http://r4ds.had.co.nz/">A book about data science in the tidyverse</a></p>
</section>
<section id="what-is-it" class="slide level2">
<h2>What is it?</h2>
<p>Collection of R packages designed to work around a <a href="https://cran.r-project.org/web/packages/tidyverse/vignettes/manifesto.html">common philosophy</a>.</p>
<center>
<img src="images/data-science-model.png" width="700px" />
</center>
</section>
<section id="what-is-it-1" class="slide level2">
<h2>What is it?</h2>
<p>Collection of R packages designed to work around a <a href="https://cran.r-project.org/web/packages/tidyverse/vignettes/manifesto.html">common philosophy</a>.</p>
<center>
<img src="images/data-science-model-packages.png" width="700px" />
</center>
</section>
<section id="two-tidyverse-components-covered-today" class="slide level2">
<h2>Two tidyverse components covered today</h2>
<center>
<img src="images/tidyr.png" width="200px" />
</center>
<center>
<img src="images/pipe.png" width="200px" />
</center>
</section>
<section id="tidy-data" class="slide level2">
<h2>Tidy data</h2>
<center>
<img src="images/tidy_1.png" width="800px" />
</center>
<ul>
<li>Each variable must have its own column.<br />
</li>
<li>Each observation must have its own row.<br />
</li>
<li>Each value must have its own cell.</li>
</ul>
</section>
<section id="why-tidy-data" class="slide level2">
<h2>Why tidy data</h2>
<ul>
<li>Consistent data structure allows easier learning of related tools because they have an underlying uniformity<br />
</li>
<li>Placing variables in columns takes advantage of R’s vectorized nature<br />
</li>
<li><a href="http://vita.had.co.nz/papers/tidy-data.pdf">Hadley’s tidy data publication</a></li>
</ul>
</section>
<section id="very-easy-to-find-data-that-is-well-organized-but-not-tidy" class="slide level2">
<h2>Very easy to find data that is well organized, but not tidy</h2>
<pre><code>## # A tibble: 5 × 5
## property five_cm ten_cm fifteen_cm twenty_cm
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 pH 7 6.7 6.5 6.4
## 2 NO3 35 22.0 20.0 18.0
## 3 clay 20 20.0 20.0 20.0
## 4 silt 20 20.0 20.0 20.0
## 5 sand 60 60.0 60.0 60.0</code></pre>
<p>Plot the change in pH across depth?</p>
</section>
<section id="gather" class="slide level2">
<h2><code>gather</code></h2>
<p>When column names are <em>values</em> instead of variables, we need to <code>gather</code></p>
<pre><code>## # A tibble: 5 × 5
## property five_cm ten_cm fifteen_cm twenty_cm
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 pH 7 6.7 6.5 6.4
## 2 NO3 35 22.0 20.0 18.0
## 3 clay 20 20.0 20.0 20.0
## 4 silt 20 20.0 20.0 20.0
## 5 sand 60 60.0 60.0 60.0</code></pre>
<ul>
<li>We need to know:<br />
</li>
<li>The columns that are the values that need to be incorporated<br />
</li>
<li>The name of the variable for the values, here it is <code>depth</code>. This is the <code>key</code>.</li>
</ul>
</section>
<section id="gather-1" class="slide level2">
<h2><code>gather</code></h2>
<pre><code>## # A tibble: 5 × 5
## property five_cm ten_cm fifteen_cm twenty_cm
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 pH 7 6.7 6.5 6.4
## 2 NO3 35 22.0 20.0 18.0
## 3 clay 20 20.0 20.0 20.0
## 4 silt 20 20.0 20.0 20.0
## 5 sand 60 60.0 60.0 60.0</code></pre>
<ul>
<li class="fragment next">The name of the variable whose values are spread over the cells. This is the <code>value</code>. If you know what it is, name it (NO3ppm). If you have many mixed units, you can use <code>value = value</code> or <code>value = measured</code> etc.</li>
</ul>
</section>
<section id="gather-2" class="slide level2">
<h2><code>gather</code></h2>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">tidy_soil<-<span class="kw">gather</span>(soil, five_cm, ten_cm, fifteen_cm, twenty_cm,
<span class="dt">key=</span>depth, <span class="dt">value=</span>value)
tidy_soil</code></pre></div>
<pre><code>## # A tibble: 20 × 3
## property depth value
## <chr> <chr> <dbl>
## 1 pH five_cm 7.0
## 2 NO3 five_cm 35.0
## 3 clay five_cm 20.0
## 4 silt five_cm 20.0
## 5 sand five_cm 60.0
## 6 pH ten_cm 6.7
## 7 NO3 ten_cm 22.0
## 8 clay ten_cm 20.0
## 9 silt ten_cm 20.0
## 10 sand ten_cm 60.0
## 11 pH fifteen_cm 6.5
## 12 NO3 fifteen_cm 20.0
## 13 clay fifteen_cm 20.0
## 14 silt fifteen_cm 20.0
## 15 sand fifteen_cm 60.0
## 16 pH twenty_cm 6.4
## 17 NO3 twenty_cm 18.0
## 18 clay twenty_cm 20.0
## 19 silt twenty_cm 20.0
## 20 sand twenty_cm 60.0</code></pre>
</section>
<section id="section" class="slide level2">
<h2></h2>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">filter</span>(tidy_soil, property ==<span class="st"> "pH"</span>)%>%
<span class="kw">ggplot</span>(<span class="kw">aes</span>(<span class="dt">x=</span><span class="kw">factor</span>(depth, <span class="dt">levels =</span> <span class="kw">c</span>(<span class="st">"five_cm"</span>, <span class="st">"ten_cm"</span>, <span class="st">"fifteen_cm"</span>, <span class="st">"twenty_cm"</span>)), <span class="dt">y=</span>value))+
<span class="st"> </span><span class="kw">geom_point</span>(<span class="dt">size=</span><span class="dv">3</span>)+
<span class="st"> </span><span class="kw">labs</span>(<span class="dt">x=</span><span class="st">"depth"</span>, <span class="dt">y=</span><span class="st">"pH"</span>)</code></pre></div>
<p><img src="slides_tidyverse_files/figure-revealjs/unnamed-chunk-6-1.png" width="768" /></p>
</section>
<section id="see-also-spread" class="slide level2">
<h2>See also <code>spread</code></h2>
<p>Use this if one of your columns is full of what could be headers</p>
<pre><code>## # A tibble: 6 × 4
## Year Commodity `Data Item` Value
## <int> <chr> <chr> <dbl>
## 1 2015 OATS OATS - ACRES HARVESTED 57000
## 2 2015 OATS OATS - ACRES PLANTED 125000
## 3 2015 OATS OATS - PRODUCTION, MEASURED IN $ 11027000
## 4 2015 OATS OATS - PRODUCTION, MEASURED IN BU 4161000
## 5 2015 OATS OATS - YIELD, MEASURED IN BU / ACRE 73
## 6 2014 OATS OATS - ACRES HARVESTED 55000</code></pre>
<ul>
<li>Now column that includes the variable names is <code>key</code>, here it is <code>Data Item</code>.<br />
</li>
<li>Column that contains the values is the <code>value</code> column, here they already have it as <code>Value</code></li>
</ul>
</section>
<section id="section-1" class="slide level2">
<h2></h2>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">spread</span>(oats, <span class="dt">key =</span> <span class="st">`</span><span class="dt">Data Item</span><span class="st">`</span>, <span class="dt">value =</span> Value)</code></pre></div>
<pre><code>## # A tibble: 150 × 8
## Year Commodity `OATS - ACRES HARVESTED` `OATS - ACRES PLANTED`
## * <int> <chr> <dbl> <dbl>
## 1 1866 OATS 450000 NA
## 2 1867 OATS 500000 NA
## 3 1868 OATS 560000 NA
## 4 1869 OATS 610000 NA
## 5 1870 OATS 660000 NA
## 6 1871 OATS 750000 NA
## 7 1872 OATS 850000 NA
## 8 1873 OATS 910000 NA
## 9 1874 OATS 960000 NA
## 10 1875 OATS 1075000 NA
## # ... with 140 more rows, and 4 more variables: `OATS - PRODUCTION,
## # MEASURED IN $` <dbl>, `OATS - PRODUCTION, MEASURED IN BU` <dbl>, `OATS
## # - YIELD, MEASURED IN BU / ACRE` <dbl>, `OATS - YIELD, MEASURED IN BU /
## # NET PLANTED ACRE` <dbl></code></pre>
</section>
<section id="section-2" class="titleslide slide level1"><h2 class="shout">%>%</h2></section><section id="moves-or-pipes-the-result-forward-into-the-next-function" class="slide level2">
<h2><code>%>%</code> moves or “pipes” the result forward into the next function</h2>
<p><code>f(x)</code> is the same as <code>x %>% f()</code></p>
<p>*assumes the first input/argument the function wants is the data set<br />
<code>ggplot(df, aes(x = this, y = values))</code></p>
<p>vs</p>
<p><code>df %>% ggplot(aes(x = this, y = values))</code></p>
</section><section id="much-easier-to-read" class="slide level2">
<h2>Much easier to read</h2>
<p>Regular code chunks work from inside out</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">finally_last_step</span>(
<span class="kw">and_then_third</span>(
<span class="kw">then_second</span>(
<span class="kw">do_first</span>(data)
)
)
)</code></pre></div>
<p>Piping uses intuitive ordering</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">data%>%
<span class="st"> </span><span class="kw">do_first</span>()%>%
<span class="st"> </span><span class="kw">then_second</span>()%>%
<span class="st"> </span><span class="kw">and_then_third</span>()%>%
<span class="st"> </span><span class="kw">finally_last_step</span>() </code></pre></div>
</section><section id="example" class="slide level2">
<h2>Example</h2>
<pre><code>## # A tibble: 4 × 7
## trt block part may june july august
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 0 A leaf 5.5 7.5 12.5 12.5
## 2 100 A stem 5.7 6.7 7.7 7.7
## 3 130 A fruit 0.0 2.0 8.2 8.8
## 4 150 A root 12.0 14.0 22.5 22.0</code></pre>
<p>Which columns need to be incorporated?<br />
What is the <code>key</code>?<br />
What is the <code>value</code>?</p>
</section><section id="section-3" class="slide level2">
<h2></h2>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">gather</span>(biomass, may, june, july, august, <span class="dt">key =</span> month, <span class="dt">value =</span> g_m2)</code></pre></div>
<pre><code>## # A tibble: 16 × 5
## trt block part month g_m2
## <chr> <chr> <chr> <chr> <dbl>
## 1 0 A leaf may 5.5
## 2 100 A stem may 5.7
## 3 130 A fruit may 0.0
## 4 150 A root may 12.0
## 5 0 A leaf june 7.5
## 6 100 A stem june 6.7
## 7 130 A fruit june 2.0
## 8 150 A root june 14.0
## 9 0 A leaf july 12.5
## 10 100 A stem july 7.7
## 11 130 A fruit july 8.2
## 12 150 A root july 22.5
## 13 0 A leaf august 12.5
## 14 100 A stem august 7.7
## 15 130 A fruit august 8.8
## 16 150 A root august 22.0</code></pre>
</section><section id="section-4" class="slide level2">
<h2></h2>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">gather</span>(biomass, may, june, july, august, <span class="dt">key =</span> month, <span class="dt">value =</span> g_m2)%>%
<span class="st"> </span><span class="kw">group_by</span>(part, month)%>%
<span class="st"> </span><span class="kw">summarise</span>(<span class="dt">avg =</span> <span class="kw">mean</span>(g_m2))</code></pre></div>
<pre><code>## Source: local data frame [16 x 3]
## Groups: part [?]
##
## part month avg
## <chr> <chr> <dbl>
## 1 fruit august 8.8
## 2 fruit july 8.2
## 3 fruit june 2.0
## 4 fruit may 0.0
## 5 leaf august 12.5
## 6 leaf july 12.5
## 7 leaf june 7.5
## 8 leaf may 5.5
## 9 root august 22.0
## 10 root july 22.5
## 11 root june 14.0
## 12 root may 12.0
## 13 stem august 7.7
## 14 stem july 7.7
## 15 stem june 6.7
## 16 stem may 5.7</code></pre>
</section><section id="more-examples" class="slide level2">
<h2>More Examples</h2>
<p>The next two examples have non-tidyverse equivalents <a href="http://agron590-isu.github.io/lab/week_07/dataframes/script_dataframes.R">here</a>.</p>
<p>These examples come from a nice ag dataset available from the <a href="https://quickstats.nass.usda.gov/">National Agricultural Statitistics Service</a>. I’ve selected data that focuses on field crops in Iowa.</p>
<pre><code>## # A tibble: 6 × 21
## Program Year Period `Week Ending` `Geo Level` State `State ANSI`
## <chr> <int> <chr> <chr> <chr> <chr> <int>
## 1 SURVEY 2015 YEAR <NA> STATE IOWA 19
## 2 SURVEY 2015 YEAR <NA> STATE IOWA 19
## 3 SURVEY 2015 YEAR <NA> STATE IOWA 19
## 4 SURVEY 2015 YEAR <NA> STATE IOWA 19
## 5 SURVEY 2015 YEAR <NA> STATE IOWA 19
## 6 SURVEY 2015 YEAR <NA> STATE IOWA 19
## # ... with 14 more variables: `Ag District` <chr>, `Ag District
## # Code` <chr>, County <chr>, `County ANSI` <chr>, `Zip Code` <chr>,
## # Region <chr>, watershed_code <chr>, Watershed <chr>, Commodity <chr>,
## # `Data Item` <chr>, Domain <chr>, `Domain Category` <chr>, Value <dbl>,
## # `CV (%)` <chr></code></pre>
</section><section id="corn-eras" class="slide level2">
<h2>Corn “eras”</h2>
<p>We read this dataframe in above as “crops”</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">crops%>%
<span class="st"> </span><span class="kw">select</span>(Year, State, Commodity, <span class="st">`</span><span class="dt">Data Item</span><span class="st">`</span>, Value)%>%<span class="st"> </span>
<span class="st"> </span><span class="kw">rename</span>(<span class="dt">Data =</span> <span class="st">`</span><span class="dt">Data Item</span><span class="st">`</span>, <span class="dt">bu_acre =</span> Value)%>%<span class="st"> </span>
<span class="st"> </span><span class="kw">filter</span>(Year ><span class="st"> </span><span class="dv">1866</span>,
Data ==<span class="st"> "CORN, GRAIN - YIELD, MEASURED IN BU / ACRE"</span>)%>%<span class="st"> </span>
<span class="st"> </span><span class="kw">mutate</span>(<span class="dt">era =</span> <span class="kw">ifelse</span> ((Year %in%<span class="st"> </span><span class="kw">c</span>(<span class="dv">1867</span>:<span class="dv">1940</span>)), <span class="st">"prehybrid"</span>,
<span class="kw">ifelse</span>((Year %in%<span class="st"> </span><span class="kw">c</span>(<span class="dv">1941</span>:<span class="dv">1990</span>)), <span class="st">"old"</span>,
<span class="kw">ifelse</span> ((Year %in%<span class="st"> </span><span class="kw">c</span>(<span class="dv">1991</span>:<span class="dv">2015</span>)),
<span class="st">"new"</span>, <span class="st">"nope"</span>))))%>%
<span class="st"> </span><span class="kw">ggplot</span>(<span class="kw">aes</span>(<span class="dt">x=</span>Year, <span class="dt">y=</span>bu_acre, <span class="dt">group=</span>era, <span class="dt">color=</span>era))+<span class="st"> </span>
<span class="st"> </span><span class="kw">geom_point</span>()+
<span class="st"> </span><span class="kw">geom_smooth</span>(<span class="dt">method=</span>lm)</code></pre></div>
</section><section id="section-5" class="slide level2">
<h2></h2>
<p><img src="slides_tidyverse_files/figure-revealjs/unnamed-chunk-17-1.png" width="768" /></p>
</section><section id="shift-from-small-grains" class="slide level2">
<h2>Shift from small grains</h2>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">crops%>%
<span class="st"> </span><span class="kw">select</span>(Year, State, Commodity, <span class="st">`</span><span class="dt">Data Item</span><span class="st">`</span>, Value)%>%
<span class="st"> </span><span class="kw">filter</span>(Commodity %in%<span class="st"> </span><span class="kw">c</span>(<span class="st">"OATS"</span>, <span class="st">"BARLEY"</span>, <span class="st">"WHEAT"</span>, <span class="st">"RYE"</span>, <span class="st">"SOYBEANS"</span>) &<span class="st"> </span>
<span class="st"> `</span><span class="dt">Data Item</span><span class="st">`</span> %in%<span class="st"> </span><span class="kw">c</span>(<span class="st">"OATS - ACRES HARVESTED"</span>,
<span class="st">"BARLEY - ACRES HARVESTED"</span>,
<span class="st">"WHEAT - ACRES HARVESTED"</span>,
<span class="st">"RYE - ACRES HARVESTED"</span>,
<span class="st">"SOYBEANS - ACRES HARVESTED"</span>))%>%
<span class="st"> </span><span class="kw">mutate</span>(<span class="dt">size =</span> <span class="kw">ifelse</span> ((Commodity %in%<span class="st"> </span><span class="kw">c</span>(<span class="st">"OATS"</span>, <span class="st">"BARLEY"</span>, <span class="st">"WHEAT"</span>, <span class="st">"RYE"</span>)),
<span class="st">"small"</span>,<span class="st">"soybean"</span>))%>%
<span class="st"> </span><span class="kw">group_by</span>(size, Year)%>%
<span class="st"> </span><span class="kw">summarise</span>(<span class="dt">total=</span><span class="kw">sum</span>(Value))%>%
<span class="st"> </span><span class="kw">ggplot</span>(<span class="kw">aes</span>(<span class="dt">x=</span>Year, <span class="dt">y=</span>total, <span class="dt">group=</span>size, <span class="dt">color=</span>size))+
<span class="st"> </span><span class="kw">geom_point</span>()+
<span class="st"> </span><span class="kw">geom_smooth</span>()+
<span class="st"> </span><span class="kw">ggtitle</span>(<span class="st">"Changes in small grain and soybean acres in Iowa"</span>)+
<span class="st"> </span><span class="kw">labs</span>(<span class="dt">y=</span><span class="st">"Total acres harvested"</span>)</code></pre></div>
</section><section id="section-6" class="slide level2">
<h2></h2>
<p><img src="slides_tidyverse_files/figure-revealjs/unnamed-chunk-19-1.png" width="768" /></p>
</section><section id="any-more-ideas-of-what-we-want-to-look-at-with-time-remaining" class="slide level2">
<h2>Any more ideas of what we want to look at with time remaining?</h2>
<center>
<img src="images/coding.gif" width="600px" />
</center>
</section>
<!--
To hide progress bar from entire presentation
just remove “progress” element.
-->
<!-- <div class="progress"></div> -->
<script src="slides_tidyverse_files\rmdshower/node_modules/shower/node_modules/shower-core/shower.min.js"></script>
<!-- Copyright © 2015 Yours Truly, Famous Inc. -->
<!-- Photos by John Carey, fiftyfootshadows.net -->
<script>renderMathInElement(document.body);</script>
</body>
</html>