-
Notifications
You must be signed in to change notification settings - Fork 0
/
rmarkdown.html
1126 lines (996 loc) · 36.9 KB
/
rmarkdown.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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<title></title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="libs/reveal.js-3.3.0.1/css/reveal.css"/>
<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>
<link rel="stylesheet" href="libs/reveal.js-3.3.0.1/css/theme/simple.css" id="theme">
<!-- some tweaks to reveal css -->
<style type="text/css">
.reveal h1 { font-size: 2.0em; }
.reveal h2 { font-size: 1.5em; }
.reveal h3 { font-size: 1.25em; }
.reveal h4 { font-size: 1em; }
.reveal .slides>section,
.reveal .slides>section>section {
padding: 0px 0px;
}
.reveal table {
border-width: 1px;
border-spacing: 2px;
border-style: dotted;
border-color: gray;
border-collapse: collapse;
font-size: 0.7em;
}
.reveal table th {
border-width: 1px;
padding-left: 10px;
padding-right: 25px;
font-weight: bold;
border-style: dotted;
border-color: gray;
}
.reveal table td {
border-width: 1px;
padding-left: 10px;
padding-right: 25px;
border-style: dotted;
border-color: gray;
}
</style>
<style type="text/css">code{white-space: pre;}</style>
<link rel="stylesheet" href="assets/theme_white.css"/>
<!-- Printing and PDF exports -->
<script id="paper-css" type="application/dynamic-css">
/* Default Print Stylesheet Template
by Rob Glazebrook of CSSnewbie.com
Last Updated: June 4, 2008
Feel free (nay, compelled) to edit, append, and
manipulate this file as you see fit. */
@media print {
/* SECTION 1: Set default width, margin, float, and
background. This prevents elements from extending
beyond the edge of the printed page, and prevents
unnecessary background images from printing */
html {
background: #fff;
width: auto;
height: auto;
overflow: visible;
}
body {
background: #fff;
font-size: 20pt;
width: auto;
height: auto;
border: 0;
margin: 0 5%;
padding: 0;
overflow: visible;
float: none !important;
}
/* SECTION 2: Remove any elements not needed in print.
This would include navigation, ads, sidebars, etc. */
.nestedarrow,
.controls,
.fork-reveal,
.share-reveal,
.state-background,
.reveal .progress,
.reveal .backgrounds {
display: none !important;
}
/* SECTION 3: Set body font face, size, and color.
Consider using a serif font for readability. */
body, p, td, li, div {
font-size: 20pt!important;
font-family: Georgia, "Times New Roman", Times, serif !important;
color: #000;
}
/* SECTION 4: Set heading font face, sizes, and color.
Differentiate your headings from your body text.
Perhaps use a large sans-serif for distinction. */
h1,h2,h3,h4,h5,h6 {
color: #000!important;
height: auto;
line-height: normal;
font-family: Georgia, "Times New Roman", Times, serif !important;
text-shadow: 0 0 0 #000 !important;
text-align: left;
letter-spacing: normal;
}
/* Need to reduce the size of the fonts for printing */
h1 { font-size: 28pt !important; }
h2 { font-size: 24pt !important; }
h3 { font-size: 22pt !important; }
h4 { font-size: 22pt !important; font-variant: small-caps; }
h5 { font-size: 21pt !important; }
h6 { font-size: 20pt !important; font-style: italic; }
/* SECTION 5: Make hyperlinks more usable.
Ensure links are underlined, and consider appending
the URL to the end of the link for usability. */
a:link,
a:visited {
color: #000 !important;
font-weight: bold;
text-decoration: underline;
}
/*
.reveal a:link:after,
.reveal a:visited:after {
content: " (" attr(href) ") ";
color: #222 !important;
font-size: 90%;
}
*/
/* SECTION 6: more reveal.js specific additions by @skypanther */
ul, ol, div, p {
visibility: visible;
position: static;
width: auto;
height: auto;
display: block;
overflow: visible;
margin: 0;
text-align: left !important;
}
.reveal pre,
.reveal table {
margin-left: 0;
margin-right: 0;
}
.reveal pre code {
padding: 20px;
border: 1px solid #ddd;
}
.reveal blockquote {
margin: 20px 0;
}
.reveal .slides {
position: static !important;
width: auto !important;
height: auto !important;
left: 0 !important;
top: 0 !important;
margin-left: 0 !important;
margin-top: 0 !important;
padding: 0 !important;
zoom: 1 !important;
overflow: visible !important;
display: block !important;
text-align: left !important;
-webkit-perspective: none;
-moz-perspective: none;
-ms-perspective: none;
perspective: none;
-webkit-perspective-origin: 50% 50%;
-moz-perspective-origin: 50% 50%;
-ms-perspective-origin: 50% 50%;
perspective-origin: 50% 50%;
}
.reveal .slides section {
visibility: visible !important;
position: static !important;
width: auto !important;
height: auto !important;
display: block !important;
overflow: visible !important;
left: 0 !important;
top: 0 !important;
margin-left: 0 !important;
margin-top: 0 !important;
padding: 60px 20px !important;
z-index: auto !important;
opacity: 1 !important;
page-break-after: always !important;
-webkit-transform-style: flat !important;
-moz-transform-style: flat !important;
-ms-transform-style: flat !important;
transform-style: flat !important;
-webkit-transform: none !important;
-moz-transform: none !important;
-ms-transform: none !important;
transform: none !important;
-webkit-transition: none !important;
-moz-transition: none !important;
-ms-transition: none !important;
transition: none !important;
}
.reveal .slides section.stack {
padding: 0 !important;
}
.reveal section:last-of-type {
page-break-after: avoid !important;
}
.reveal section .fragment {
opacity: 1 !important;
visibility: visible !important;
-webkit-transform: none !important;
-moz-transform: none !important;
-ms-transform: none !important;
transform: none !important;
}
.reveal section img {
display: block;
margin: 15px 0px;
background: rgba(255,255,255,1);
border: 1px solid #666;
box-shadow: none;
}
.reveal section small {
font-size: 0.8em;
}
}
</script>
<script id="pdf-css" type="application/dynamic-css">
/**
* This stylesheet is used to print reveal.js
* presentations to PDF.
*
* https://github.com/hakimel/reveal.js#pdf-export
*/
* {
-webkit-print-color-adjust: exact;
}
body {
margin: 0 auto !important;
border: 0;
padding: 0;
float: none !important;
overflow: visible;
}
html {
width: 100%;
height: 100%;
overflow: visible;
}
/* Remove any elements not needed in print. */
.nestedarrow,
.reveal .controls,
.reveal .progress,
.reveal .playback,
.reveal.overview,
.fork-reveal,
.share-reveal,
.state-background {
display: none !important;
}
h1, h2, h3, h4, h5, h6 {
text-shadow: 0 0 0 #000 !important;
}
.reveal pre code {
overflow: hidden !important;
font-family: Courier, 'Courier New', monospace !important;
}
ul, ol, div, p {
visibility: visible;
position: static;
width: auto;
height: auto;
display: block;
overflow: visible;
margin: auto;
}
.reveal {
width: auto !important;
height: auto !important;
overflow: hidden !important;
}
.reveal .slides {
position: static;
width: 100%;
height: auto;
left: auto;
top: auto;
margin: 0 !important;
padding: 0 !important;
overflow: visible;
display: block;
-webkit-perspective: none;
-moz-perspective: none;
-ms-perspective: none;
perspective: none;
-webkit-perspective-origin: 50% 50%; /* there isn't a none/auto value but 50-50 is the default */
-moz-perspective-origin: 50% 50%;
-ms-perspective-origin: 50% 50%;
perspective-origin: 50% 50%;
}
.reveal .slides section {
page-break-after: always !important;
visibility: visible !important;
position: relative !important;
display: block !important;
position: relative !important;
margin: 0 !important;
padding: 0 !important;
box-sizing: border-box !important;
min-height: 1px;
opacity: 1 !important;
-webkit-transform-style: flat !important;
-moz-transform-style: flat !important;
-ms-transform-style: flat !important;
transform-style: flat !important;
-webkit-transform: none !important;
-moz-transform: none !important;
-ms-transform: none !important;
transform: none !important;
}
.reveal section.stack {
margin: 0 !important;
padding: 0 !important;
page-break-after: avoid !important;
height: auto !important;
min-height: auto !important;
}
.reveal img {
box-shadow: none;
}
.reveal .roll {
overflow: visible;
line-height: 1em;
}
/* Slide backgrounds are placed inside of their slide when exporting to PDF */
.reveal section .slide-background {
display: block !important;
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: -1;
}
/* All elements should be above the slide-background */
.reveal section>* {
position: relative;
z-index: 1;
}
/* Display slide speaker notes when 'showNotes' is enabled */
.reveal .speaker-notes-pdf {
display: block;
width: 100%;
max-height: none;
left: auto;
top: auto;
z-index: 100;
}
/* Display slide numbers when 'slideNumber' is enabled */
.reveal .slide-number-pdf {
display: block;
position: absolute;
font-size: 14px;
}
</script>
<script>
var style = document.createElement( 'style' );
style.type = 'text/css';
var style_script_id = window.location.search.match( /print-pdf/gi ) ? 'pdf-css' : 'paper-css';
var style_script = document.getElementById(style_script_id).text;
style.innerHTML = style_script;
document.getElementsByTagName('head')[0].appendChild(style);
</script>
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<style> .reveal i.fa { font-family:FontAwesome; font-style: normal; } </style>
<script src="libs/htmlwidgets-0.8/htmlwidgets.js"></script>
<script src="libs/jquery-1.12.4/jquery.min.js"></script>
<script src="libs/datatables-binding-0.2/datatables.js"></script>
<link href="libs/dt-core-1.10.12/css/jquery.dataTables.min.css" rel="stylesheet" />
<link href="libs/dt-core-1.10.12/css/jquery.dataTables.extra.css" rel="stylesheet" />
<script src="libs/dt-core-1.10.12/js/jquery.dataTables.min.js"></script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section id="r-markdown" class="slide level1">
<h1>R Markdown</h1>
<p><img src="images/rmarkdown.png" /></p>
<aside class="notes" data-markdown>
</aside>
</section>
<section id="what-is-r-markdown" class="slide level1" data-background="#401F68">
<h1>What is<br>R Markdown?</h1>
<aside class="notes" data-markdown>
<p>You may have seen the R Markdown file type when you go to make a new document in RStudio, or see documents with R code published online and have some awareness that they were made with this thing called R Markdown.</p>
<p>R Markdown is a way to write a document with executable R code in it.</p>
You may want to show both the code and the output, or you may just want to use R generate output that is integrated with other text or content, leaving out the R code.
</aside>
</section>
<section class="slide level1">
<p><a href="http://rmarkdown.rstudio.com/gallery.html">Gallery</a></p>
<p><a href="https://rpubs.com/">RPubs</a></p>
<p><a href="https://github.com/juba/rmdformats">Formatted Templates</a></p>
<p><a href="https://github.com/nuitrcs/rworkshops">Research Computing Workshop</a> <a href="https://nuitrcs.github.io/ggplotworkshop/ggplot.html">Files</a></p>
</section>
<section id="why" class="slide level1" data-background="#401F68">
<h1>Why?</h1>
</section>
<section class="slide level1">
<h2 id="reproducible-workflows">Reproducible Workflows</h2>
</section>
<section class="slide level1">
<p><a href="https://www.youtube.com/embed/s3JldKoA0zw?showinfo=0&rel=0">video</a></p>
</section>
<section class="slide level1">
<h2 id="version-control">Version Control</h2>
<p><img src="images/versioncontrol.gif" alt="version control" /></p>
<div class="caption">
<a href="http://phdcomics.com/comics/archive_print.php?comicid=1531">Piled Higher and Deeper by Jorge Cham</a>
</div>
<aside class="notes" data-markdown>
<p>R Markdown documents are plain text, so you can easily track changes with git or other version control systems.</p>
Previews in GitHub, or post html there
</aside>
</section>
<section class="slide level1">
<h2 id="multiple-versions">Multiple Versions</h2>
<p><img src="images/RMarkdownOutputFormats.png" alt="output" /></p>
<div class="caption">
<a href="http://rmarkdown.rstudio.com/authoring_quick_tour.html">Source</a>
</div>
<aside class="notes" data-markdown>
HTML for the web, pdf for distribution, Word for your coauthor to work with.
</aside>
</section>
<section class="slide level1">
<h2 id="easy-for-you-and-your-audience">Easy for you and your Audience</h2>
<p><img src="https://media.giphy.com/media/3o7btNa0RUYa5E7iiQ/giphy.gif" height=300px></p>
<aside class="notes" data-markdown>
<p>Make your code and its output accessible to both people who may know R and people who don’t. You have the option to hide your code entirely (or use code folding).</p>
<p>I’ve had a number of students tell me that they use R or want to use R, but their advisor doesn’t. They don’t want to send their advisor R code, but it can take a lot of time to reformat output, write it up, etc. With R markdown, sharing is easier.</p>
In my position, I may be sending results of an analysis to someone who is only interested in that – but I don’t have to do a separate write-up from my code. I can have tables, multiple figures, notes – everything in one place, in one document (can compile into a single, sharable document.
</aside>
</section>
<section class="slide level1">
<h2 id="multiple-audiences">Multiple Audiences</h2>
<p><img src="images/audiences.jpg" alt="audiences" /></p>
<aside class="notes" data-markdown>
<p>Lecture Notes</p>
<p>Assignments/Problem Sets</p>
<p>Internal vs. External</p>
<p>Create instructor versions with notes, assignment, and answer key versions of problem sets or lecture notes all from the same source document.</p>
Set which chunks of code or text will be displayed or evaluated with variables.
</aside>
</section>
<section class="slide level1">
<h2 id="kindness-to-future-self">Kindness to Future Self</h2>
<p><img src="https://media.giphy.com/media/26gmFUFEvc3cuZiak/giphy.gif" alt="kind" /></p>
<aside class="notes" data-markdown>
<p>One important audience is your future self.</p>
<p>Typing comment lines in R can be cumbersome. That approach works well for scripts, but for analysis, you need more words.</p>
<p>I’m guessing I’m not the only one who has opened up an old analysis script and had no idea what I was doing or thinking. Why did I exclude those cases? How did I decide on that model specification?</p>
With R Markdown, writing text with the code is easy, which makes it more likely that you’ll do it!
</aside>
</section>
<section id="how-does-it-work" class="slide level1" data-background="#401F68">
<h1>How does it work?</h1>
</section>
<section class="slide level1">
<p><img src="images/RMarkdownFlow.png" alt="R Markdown Flow" /></p>
<div class="caption">
Source: <a href="http://rmarkdown.rstudio.com/lesson-2.html">R Markdown Website</a>
</div>
<aside class="notes" data-markdown>
<p>Markdown lets you write plain text, with some basic formatting. <strong>R</strong> Markdown lets you add chunks of R code to a markdown document. When you compile or “knit” the document, R Markdown then executes those code chunks and incorporates the output and results into a markdown document. That markdown document with the text, code, and results is then compiled into html (for the web), pdf, or Word document, in a variety of different formats.</p>
</aside>
</section>
<section class="slide level1">
<h2 id="r-markdown-1">R Markdown</h2>
<pre>
---
output:
html_document:
keep_md: true
---
# Header 1
Markdown text, **bold**, *italics*,
[a link](http://google.com).
```{r}
summary(cars)
```
</pre>
</section>
<section class="slide level1">
<h2 id="markdown">Markdown</h2>
<pre>
# Header 1
Markdown text, **bold**, *italics*,
[a link](http://google.com).
```r
summary(cars)
```
```
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
```
</pre>
</section>
<section class="slide level1">
<h2 id="html-code">HTML Code</h2>
<pre>
<h1>Header 1</h1>
<p>Markdown text, <strong>bold</strong>,
<em>italics</em>,
<a href="http://google.com">a link</a>.</p>
<pre class="r"><code>summary(cars)</code></pre>
<pre><code>## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00</code></pre>
</div>
</pre>
</section>
<section id="header-1" class="slide level1">
<h1>Header 1</h1>
<p>Markdown text, <strong>bold</strong>, <em>italics</em>, <a href="http://google.com">a link</a>.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">summary</span>(cars)</code></pre></div>
<pre><code>## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00</code></pre>
</section>
<section class="slide level1">
<p><img src="images/simplehtml.jpeg" /></p>
</section>
<section class="slide level1">
<h2 id="compilation-options">Compilation Options</h2>
<p>RStudio Knit Button</p>
<p><img src="images/knitbutton.jpeg" alt="knit" /></p>
<p><code>rmarkdown::render()</code></p>
</section>
<section class="slide level1">
<p><img src="images/chunks.png" alt="chunks" /></p>
<div class="caption">
Source: <a href="https://stat585-at-isu.github.io/materials/01_collaborative-environment/03_rmarkdown.html#">Heike Hofman</a>
</div>
</section>
<section class="slide level1">
<h2 id="yaml-header">YAML Header</h2>
<p>Spacing matters</p>
<p>Look up the options: <a href="http://rmarkdown.rstudio.com/formats.html">R Markdown Formats</a></p>
<aside class="notes" data-markdown>
<p>Spacing - indentation, where colons and other punctuation are, etc. – pay attention</p>
You can override options set here with a call to render
</aside>
</section>
<section class="slide level1">
<h2 id="text-chunks-markdown">Text Chunks: Markdown</h2>
<pre><code># Header 1
## Header 2
### Header 3
*Italics*
**Bold**
[link text](http://google.com)
![caption][images/image.png]
- List Item 1
- List Item 2
- Item 2a
- Item 2b
1. Numbered list item 1
1. Numbered list item 2</code></pre>
<aside class="notes" data-markdown>
<p>The second 1 in the numbered list isn’t a typo – makes it easier to reorder points</p>
Markdown is also used on GitHub. It’s easy for including formatted code chunks. It’s plain text, but still gives you some formatting capabilities.
</aside>
</section>
<section class="slide level1">
<p><img src="images/chunks.png" alt="chunks" /></p>
<div class="caption">
Source: <a href="https://stat585-at-isu.github.io/materials/01_collaborative-environment/03_rmarkdown.html#">Heike Hofman</a>
</div>
</section>
<section class="slide level1">
<h2 id="options-chunk">Options chunk</h2>
<pre>
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
</pre>
<aside class="notes" data-markdown>
<p>This isn’t necessarily required</p>
and what’s in this example doesn’t change the default behavior
</aside>
</section>
<section class="slide level1">
<h2 id="r-chunks">R chunks</h2>
<pre>
```{r chunkname}
a<-2
a + 1
a<-3
a + 2
```
</pre>
<aside class="notes" data-markdown>
<p>chunk names will get auto generated if you don’t set them</p>
<p>chunk names need to be unique – can come up if automatically generating chunks (a bit of a hack)</p>
<p>if creating external figures, chunk names will get used</p>
can make it easier to find errors
</aside>
</section>
<section class="slide level1">
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">a<-<span class="dv">2</span>
a <span class="op">+</span><span class="st"> </span><span class="dv">1</span></code></pre></div>
<pre><code>## [1] 3</code></pre>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">a<-<span class="dv">3</span>
a <span class="op">+</span><span class="st"> </span><span class="dv">2</span></code></pre></div>
<pre><code>## [1] 5</code></pre>
<aside class="notes" data-markdown>
Chunk was automatically divided
</aside>
</section>
<section class="slide level1">
<h2 id="plot">Plot</h2>
<pre>
```{r, fig.width=8, echo=FALSE}
plot(cars)
```
</pre>
</section>
<section class="slide level1">
<p><img src="rmarkdown_files/figure-revealjs/unnamed-chunk-2-1.png" width="768" /></p>
</section>
<section class="slide level1">
<h2 id="pretty-output-with-knitrkable">Pretty Output with <code>knitr::kable</code></h2>
</section>
<section class="slide level1">
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">head</span>(mtcars)</code></pre></div>
<pre><code>## mpg cyl disp hp drat wt
## Mazda RX4 21.0 6 160 110 3.90 2.620
## Mazda RX4 Wag 21.0 6 160 110 3.90 2.875
## Datsun 710 22.8 4 108 93 3.85 2.320
## Hornet 4 Drive 21.4 6 258 110 3.08 3.215
## Hornet Sportabout 18.7 8 360 175 3.15 3.440
## Valiant 18.1 6 225 105 2.76 3.460
## qsec vs am gear carb
## Mazda RX4 16.46 0 1 4 4
## Mazda RX4 Wag 17.02 0 1 4 4
## Datsun 710 18.61 1 1 4 1
## Hornet 4 Drive 19.44 1 0 3 1
## Hornet Sportabout 17.02 0 0 3 2
## Valiant 20.22 1 0 3 1</code></pre>
</section>
<section class="slide level1">
<pre>
```{r, results='asis'}
library(knitr)
kable(head(cars))
```
</pre>
<table>
<thead>
<tr class="header">
<th></th>
<th style="text-align: right;">mpg</th>
<th style="text-align: right;">cyl</th>
<th style="text-align: right;">disp</th>
<th style="text-align: right;">hp</th>
<th style="text-align: right;">drat</th>
<th style="text-align: right;">wt</th>
<th style="text-align: right;">qsec</th>
<th style="text-align: right;">vs</th>
<th style="text-align: right;">am</th>
<th style="text-align: right;">gear</th>
<th style="text-align: right;">carb</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Mazda RX4</td>
<td style="text-align: right;">21.0</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">160</td>
<td style="text-align: right;">110</td>
<td style="text-align: right;">3.90</td>
<td style="text-align: right;">2.620</td>
<td style="text-align: right;">16.46</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">4</td>
</tr>
<tr class="even">
<td>Mazda RX4 Wag</td>
<td style="text-align: right;">21.0</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">160</td>
<td style="text-align: right;">110</td>
<td style="text-align: right;">3.90</td>
<td style="text-align: right;">2.875</td>
<td style="text-align: right;">17.02</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">4</td>
</tr>
<tr class="odd">
<td>Datsun 710</td>
<td style="text-align: right;">22.8</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">108</td>
<td style="text-align: right;">93</td>
<td style="text-align: right;">3.85</td>
<td style="text-align: right;">2.320</td>
<td style="text-align: right;">18.61</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">4</td>
<td style="text-align: right;">1</td>
</tr>
<tr class="even">
<td>Hornet 4 Drive</td>
<td style="text-align: right;">21.4</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">258</td>
<td style="text-align: right;">110</td>
<td style="text-align: right;">3.08</td>
<td style="text-align: right;">3.215</td>
<td style="text-align: right;">19.44</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1</td>
</tr>
<tr class="odd">
<td>Hornet Sportabout</td>
<td style="text-align: right;">18.7</td>
<td style="text-align: right;">8</td>
<td style="text-align: right;">360</td>
<td style="text-align: right;">175</td>
<td style="text-align: right;">3.15</td>
<td style="text-align: right;">3.440</td>
<td style="text-align: right;">17.02</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">2</td>
</tr>
<tr class="even">
<td>Valiant</td>
<td style="text-align: right;">18.1</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">225</td>
<td style="text-align: right;">105</td>
<td style="text-align: right;">2.76</td>
<td style="text-align: right;">3.460</td>
<td style="text-align: right;">20.22</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">1</td>
</tr>
</tbody>
</table>
<aside class="notes" data-markdown>
<p>kable creates table in format appropriate for output type</p>
results asis prevents further processing of output
</aside>
</section>
<section class="slide level1">
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">summary</span>(<span class="kw">lm</span>(mpg <span class="op">~</span><span class="st"> </span>hp <span class="op">+</span><span class="st"> </span>disp, <span class="dt">data=</span>mtcars))</code></pre></div>
<pre><code>##
## Call:
## lm(formula = mpg ~ hp + disp, data = mtcars)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.7945 -2.3036 -0.8246 1.8582 6.9363
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 30.735904 1.331566 23.083 < 2e-16
## hp -0.024840 0.013385 -1.856 0.073679
## disp -0.030346 0.007405 -4.098 0.000306
##
## (Intercept) ***
## hp .
## disp ***
## ---
## Signif. codes:
## 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.127 on 29 degrees of freedom
## Multiple R-squared: 0.7482, Adjusted R-squared: 0.7309
## F-statistic: 43.09 on 2 and 29 DF, p-value: 2.062e-09</code></pre>
</section>
<section class="slide level1">
<pre>
```{r, results='asis'}
reg1 <- lm(mpg ~ hp + disp, data=mtcars)
kable(summary(reg1)$coef, digits=2)
```
</pre>
<table>
<thead>
<tr class="header">
<th></th>
<th style="text-align: right;">Estimate</th>
<th style="text-align: right;">Std. Error</th>
<th style="text-align: right;">t value</th>
<th style="text-align: right;">Pr(>|t|)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>(Intercept)</td>
<td style="text-align: right;">30.74</td>
<td style="text-align: right;">1.33</td>
<td style="text-align: right;">23.08</td>
<td style="text-align: right;">0.00</td>
</tr>
<tr class="even">
<td>hp</td>
<td style="text-align: right;">-0.02</td>
<td style="text-align: right;">0.01</td>
<td style="text-align: right;">-1.86</td>
<td style="text-align: right;">0.07</td>
</tr>
<tr class="odd">
<td>disp</td>
<td style="text-align: right;">-0.03</td>
<td style="text-align: right;">0.01</td>
<td style="text-align: right;">-4.10</td>