33% found this document useful (3 votes)
311 views123 pages

R Markdown: The Definitive Guide: Yihui Xie, J. J. Allaire, Garrett Grolemund

The document provides an overview of R Markdown, which allows embedding R code and results into markdown documents. It discusses example applications of R Markdown, how to compile R Markdown documents, different output formats including HTML, PDF, and slide presentations. It also covers various features for each output format such as tables of contents, syntax highlighting, figure formatting. The document serves as a guide for using R Markdown for reports, articles, slides, dashboards, books, and other applications.

Uploaded by

Paulo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
33% found this document useful (3 votes)
311 views123 pages

R Markdown: The Definitive Guide: Yihui Xie, J. J. Allaire, Garrett Grolemund

The document provides an overview of R Markdown, which allows embedding R code and results into markdown documents. It discusses example applications of R Markdown, how to compile R Markdown documents, different output formats including HTML, PDF, and slide presentations. It also covers various features for each output format such as tables of contents, syntax highlighting, figure formatting. The document serves as a guide for using R Markdown for reports, articles, slides, dashboards, books, and other applications.

Uploaded by

Paulo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 123

Yihui Xie, J. J.

Allaire, Garrett Grolemund

R Markdown: The Definitive


Guide
To Jung Jae-sung (1982 – 2018),
a remarkably hard-working badminton player with a remarkably
simple playing style
Contents

List of Tables xvii

List of Figures xix

Preface xxiii

About the Authors xxxiii

I Get Started 1

1 Installation 5

2 Basics 7
2.1 Example applications . . . . . . . . . . . . . . . . . . . . . 7
2.1.1 Airbnb’s knowledge repository . . . . . . . . . . . . 7
2.1.2 Homework assignments on RPubs . . . . . . . . . . 7
2.1.3 Personalized mail . . . . . . . . . . . . . . . . . . . 8
2.1.4 2017 Employer Health Benefits Survey . . . . . . . . 8
2.1.5 Journal articles . . . . . . . . . . . . . . . . . . . . . 8
2.1.6 Dashboards at eelloo . . . . . . . . . . . . . . . . . 8
2.1.7 Books . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1.8 Websites . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2 Compile an R Markdown document . . . . . . . . . . . . . 8
2.3 Cheat sheets . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Output formats . . . . . . . . . . . . . . . . . . . . . . . . 9
2.5 Markdown syntax . . . . . . . . . . . . . . . . . . . . . . . 9
2.5.1 Inline formatting . . . . . . . . . . . . . . . . . . . 9
2.5.2 Block-level elements . . . . . . . . . . . . . . . . . 9
2.5.3 Math expressions . . . . . . . . . . . . . . . . . . . 9
2.6 R code chunks and inline R code . . . . . . . . . . . . . . . 10
2.6.1 Figures . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.6.2 Tables . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.7 Other language engines . . . . . . . . . . . . . . . . . . . . 10

vii
viii Contents

2.7.1 Python . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.7.2 Shell scripts . . . . . . . . . . . . . . . . . . . . . . 10
2.7.3 SQL . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.7.4 Rcpp . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.7.5 Stan . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.7.6 JavaScript and CSS . . . . . . . . . . . . . . . . . . 11
2.7.7 Julia . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.7.8 C and Fortran . . . . . . . . . . . . . . . . . . . . . 11
2.8 Interactive documents . . . . . . . . . . . . . . . . . . . . . 11
2.8.1 HTML widgets . . . . . . . . . . . . . . . . . . . . 11
2.8.2 Shiny documents . . . . . . . . . . . . . . . . . . . 12

II Output Formats 13

3 Documents 17
3.1 HTML document . . . . . . . . . . . . . . . . . . . . . . . 17
3.1.1 Table of contents . . . . . . . . . . . . . . . . . . . . 17
3.1.2 Section numbering . . . . . . . . . . . . . . . . . . 17
3.1.3 Tabbed sections . . . . . . . . . . . . . . . . . . . . 17
3.1.4 Appearance and style . . . . . . . . . . . . . . . . . 18
3.1.5 Figure options . . . . . . . . . . . . . . . . . . . . . 18
3.1.6 Data frame printing . . . . . . . . . . . . . . . . . . 18
3.1.7 Code folding . . . . . . . . . . . . . . . . . . . . . . 18
3.1.8 MathJax equations . . . . . . . . . . . . . . . . . . . 19
3.1.9 Document dependencies . . . . . . . . . . . . . . . 19
3.1.10 Advanced customization . . . . . . . . . . . . . . . 19
3.1.11 Shared options . . . . . . . . . . . . . . . . . . . . . 19
3.1.12 HTML fragments . . . . . . . . . . . . . . . . . . . 20
3.2 Notebook . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.2.1 Using Notebooks . . . . . . . . . . . . . . . . . . . 20
3.2.2 Saving and sharing . . . . . . . . . . . . . . . . . . 21
3.2.3 Notebook format . . . . . . . . . . . . . . . . . . . 21
3.3 PDF document . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.3.1 Table of contents . . . . . . . . . . . . . . . . . . . . 22
3.3.2 Figure options . . . . . . . . . . . . . . . . . . . . . 22
3.3.3 Data frame printing . . . . . . . . . . . . . . . . . . 22
3.3.4 Syntax highlighting . . . . . . . . . . . . . . . . . . 23
3.3.5 LaTeX options . . . . . . . . . . . . . . . . . . . . . 23
3.3.6 LaTeX packages for citations . . . . . . . . . . . . . 23
3.3.7 Advanced customization . . . . . . . . . . . . . . . 23
Contents ix

3.3.8 Other features . . . . . . . . . . . . . . . . . . . . . 24


3.4 Word document . . . . . . . . . . . . . . . . . . . . . . . . 24
3.4.1 Other features . . . . . . . . . . . . . . . . . . . . . 24
3.5 OpenDocument Text document . . . . . . . . . . . . . . . . 24
3.5.1 Other features . . . . . . . . . . . . . . . . . . . . . 24
3.6 Rich Text Format document . . . . . . . . . . . . . . . . . . 24
3.6.1 Other features . . . . . . . . . . . . . . . . . . . . . 25
3.7 Markdown document . . . . . . . . . . . . . . . . . . . . . 25
3.7.1 Markdown variants . . . . . . . . . . . . . . . . . . 25
3.7.2 Other features . . . . . . . . . . . . . . . . . . . . . 25
3.8 R package vignette . . . . . . . . . . . . . . . . . . . . . . 25

4 Presentations 27
4.1 ioslides presentation . . . . . . . . . . . . . . . . . . . . . . 27
4.1.1 Display modes . . . . . . . . . . . . . . . . . . . . . 27
4.1.2 Incremental bullets . . . . . . . . . . . . . . . . . . 27
4.1.3 Visual appearance . . . . . . . . . . . . . . . . . . . 27
4.1.4 Code highlighting . . . . . . . . . . . . . . . . . . . 28
4.1.5 Adding a logo . . . . . . . . . . . . . . . . . . . . . 28
4.1.6 Tables . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.1.7 Advanced layout . . . . . . . . . . . . . . . . . . . 28
4.1.8 Text color . . . . . . . . . . . . . . . . . . . . . . . 28
4.1.9 Presenter mode . . . . . . . . . . . . . . . . . . . . 29
4.1.10 Printing and PDF output . . . . . . . . . . . . . . . 29
4.1.11 Custom templates . . . . . . . . . . . . . . . . . . . 29
4.1.12 Other features . . . . . . . . . . . . . . . . . . . . . 29
4.2 Slidy presentation . . . . . . . . . . . . . . . . . . . . . . . 29
4.2.1 Display modes . . . . . . . . . . . . . . . . . . . . . 29
4.2.2 Text size . . . . . . . . . . . . . . . . . . . . . . . . 29
4.2.3 Footer elements . . . . . . . . . . . . . . . . . . . . 30
4.2.4 Other features . . . . . . . . . . . . . . . . . . . . . 30
4.3 Beamer presentation . . . . . . . . . . . . . . . . . . . . . . 30
4.3.1 Themes . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.3.2 Slide level . . . . . . . . . . . . . . . . . . . . . . . 30
4.3.3 Other features . . . . . . . . . . . . . . . . . . . . . 30
4.4 PowerPoint presentation . . . . . . . . . . . . . . . . . . . 31
4.4.1 Custom templates . . . . . . . . . . . . . . . . . . . 31
4.4.2 Other features . . . . . . . . . . . . . . . . . . . . . 31

III Extensions 33
x Contents

5 Dashboards 37
5.1 Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.1.1 Row-based layouts . . . . . . . . . . . . . . . . . . 37
5.1.2 Attributes on sections . . . . . . . . . . . . . . . . . 37
5.1.3 Multiple pages . . . . . . . . . . . . . . . . . . . . . 37
5.1.4 Story boards . . . . . . . . . . . . . . . . . . . . . . 38
5.2 Components . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.2.1 Value boxes . . . . . . . . . . . . . . . . . . . . . . 38
5.2.2 Gauges . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.2.3 Text annotations . . . . . . . . . . . . . . . . . . . . 38
5.2.4 Navigation bar . . . . . . . . . . . . . . . . . . . . . 38
5.3 Shiny . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.3.1 Getting started . . . . . . . . . . . . . . . . . . . . . 39
5.3.2 A Shiny dashboard example . . . . . . . . . . . . . 39
5.3.3 Input sidebar . . . . . . . . . . . . . . . . . . . . . 39
5.3.4 Learning more . . . . . . . . . . . . . . . . . . . . . 39

6 Tufte Handouts 41
6.1 Headings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
6.2 Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
6.2.1 Margin figures . . . . . . . . . . . . . . . . . . . . . 41
6.2.2 Arbitrary margin content . . . . . . . . . . . . . . . 41
6.2.3 Full-width figures . . . . . . . . . . . . . . . . . . . 42
6.2.4 Main column figures . . . . . . . . . . . . . . . . . 42
6.3 Sidenotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
6.4 References . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
6.5 Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
6.6 Block quotes . . . . . . . . . . . . . . . . . . . . . . . . . . 43
6.7 Responsiveness . . . . . . . . . . . . . . . . . . . . . . . . 43
6.8 Sans-serif fonts and epigraphs . . . . . . . . . . . . . . . . 43
6.9 Customize CSS styles . . . . . . . . . . . . . . . . . . . . . 43

7 xaringan Presentations 45
7.1 Get started . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
7.2 Keyboard shortcuts . . . . . . . . . . . . . . . . . . . . . . 45
7.3 Slide formatting . . . . . . . . . . . . . . . . . . . . . . . . 45
7.3.1 Slides and properties . . . . . . . . . . . . . . . . . 45
7.3.2 The title slide . . . . . . . . . . . . . . . . . . . . . 46
7.3.3 Content classes . . . . . . . . . . . . . . . . . . . . 46
7.3.4 Incremental slides . . . . . . . . . . . . . . . . . . . 46
Contents xi

7.3.5 Presenter notes . . . . . . . . . . . . . . . . . . . . 46


7.3.6 yolo: true . . . . . . . . . . . . . . . . . . . . . . . . 46
7.4 Build and preview slides . . . . . . . . . . . . . . . . . . . 46
7.5 CSS and themes . . . . . . . . . . . . . . . . . . . . . . . . 46
7.6 Some tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
7.6.1 Autoplay slides . . . . . . . . . . . . . . . . . . . . 47
7.6.2 Countdown timer . . . . . . . . . . . . . . . . . . . 47
7.6.3 Highlight code lines . . . . . . . . . . . . . . . . . . 47
7.6.4 Working offline . . . . . . . . . . . . . . . . . . . . 47
7.6.5 Macros . . . . . . . . . . . . . . . . . . . . . . . . . 47
7.6.6 Disadvantages . . . . . . . . . . . . . . . . . . . . . 47

8 reveal.js Presentations 49
8.1 Display modes . . . . . . . . . . . . . . . . . . . . . . . . . 49
8.2 Appearance and style . . . . . . . . . . . . . . . . . . . . . 49
8.2.1 Smaller text . . . . . . . . . . . . . . . . . . . . . . 49
8.3 Slide transitions . . . . . . . . . . . . . . . . . . . . . . . . 49
8.4 Slide backgrounds . . . . . . . . . . . . . . . . . . . . . . . 50
8.5 2-D presentations . . . . . . . . . . . . . . . . . . . . . . . 50
8.6 Custom CSS . . . . . . . . . . . . . . . . . . . . . . . . . . 50
8.6.1 Slide IDs and classes . . . . . . . . . . . . . . . . . 50
8.6.2 Styling text spans . . . . . . . . . . . . . . . . . . . 50
8.7 reveal.js options . . . . . . . . . . . . . . . . . . . . . . . . 50
8.8 reveal.js plugins . . . . . . . . . . . . . . . . . . . . . . . . 51
8.9 Other features . . . . . . . . . . . . . . . . . . . . . . . . . 51

9 Community Formats 53
9.1 Lightweight Pretty HTML Documents . . . . . . . . . . . . 53
9.1.1 Usage . . . . . . . . . . . . . . . . . . . . . . . . . 53
9.1.2 Package vignettes . . . . . . . . . . . . . . . . . . . 53
9.2 The rmdformats package . . . . . . . . . . . . . . . . . . . 53
9.3 Shower presentations . . . . . . . . . . . . . . . . . . . . . 54

10 Websites 55
10.1 Get started . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
10.2 The directory structure . . . . . . . . . . . . . . . . . . . . 55
10.3 Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . 55
10.4 Other site generators . . . . . . . . . . . . . . . . . . . . . 55
10.5 rmarkdown’s site generator . . . . . . . . . . . . . . . . . . 56
10.5.1 A simple example . . . . . . . . . . . . . . . . . . . 56
xii Contents

10.5.2 Site authoring . . . . . . . . . . . . . . . . . . . . . 56


10.5.3 Common elements . . . . . . . . . . . . . . . . . . 57
10.5.4 Site navigation . . . . . . . . . . . . . . . . . . . . . 57
10.5.5 HTML generation . . . . . . . . . . . . . . . . . . . 57
10.5.6 Site configuration . . . . . . . . . . . . . . . . . . . 57
10.5.7 Publishing websites . . . . . . . . . . . . . . . . . . 58
10.5.8 Additional examples . . . . . . . . . . . . . . . . . 58
10.5.9 Custom site generators . . . . . . . . . . . . . . . . 58

11 HTML Documentation for R Packages 59


11.1 Get started . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
11.2 Components . . . . . . . . . . . . . . . . . . . . . . . . . . 59
11.2.1 Home page . . . . . . . . . . . . . . . . . . . . . . 59
11.2.2 Function reference . . . . . . . . . . . . . . . . . . . 59
11.2.3 Articles . . . . . . . . . . . . . . . . . . . . . . . . . 60
11.2.4 News . . . . . . . . . . . . . . . . . . . . . . . . . . 60
11.2.5 Navigation bar . . . . . . . . . . . . . . . . . . . . . 60

12 Books 61
12.1 Get started . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
12.2 Project structure . . . . . . . . . . . . . . . . . . . . . . . . 61
12.2.1 Index file . . . . . . . . . . . . . . . . . . . . . . . . 61
12.2.2 Rmd files . . . . . . . . . . . . . . . . . . . . . . . . 61
12.2.3 _bookdown.yml . . . . . . . . . . . . . . . . . . . . 62
12.2.4 _output.yml . . . . . . . . . . . . . . . . . . . . . . 62
12.3 Markdown extensions . . . . . . . . . . . . . . . . . . . . . 62
12.3.1 Number and reference equations . . . . . . . . . . . 62
12.3.2 Theorems and proofs . . . . . . . . . . . . . . . . . 62
12.3.3 Special headers . . . . . . . . . . . . . . . . . . . . 62
12.3.4 Text references . . . . . . . . . . . . . . . . . . . . . 62
12.3.5 Cross referencing . . . . . . . . . . . . . . . . . . . 62
12.4 Output Formats . . . . . . . . . . . . . . . . . . . . . . . . 63
12.4.1 HTML . . . . . . . . . . . . . . . . . . . . . . . . . 63
12.4.2 LaTeX/PDF . . . . . . . . . . . . . . . . . . . . . . 63
12.4.3 E-books . . . . . . . . . . . . . . . . . . . . . . . . 63
12.4.4 A single document . . . . . . . . . . . . . . . . . . 63
12.5 Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
12.5.1 Build the book . . . . . . . . . . . . . . . . . . . . . 63
12.5.2 Preview a chapter . . . . . . . . . . . . . . . . . . . 64
12.5.3 Serve the book . . . . . . . . . . . . . . . . . . . . . 64
Contents xiii

12.5.4 RStudio addins . . . . . . . . . . . . . . . . . . . . 64


12.6 Publishing . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
12.6.1 RStudio Connect . . . . . . . . . . . . . . . . . . . 64
12.6.2 Other services . . . . . . . . . . . . . . . . . . . . . 64
12.6.3 Publishers . . . . . . . . . . . . . . . . . . . . . . . 64

13 Journals 65
13.1 Get started . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
13.2 rticles templates . . . . . . . . . . . . . . . . . . . . . . . . 65
13.3 Using a template . . . . . . . . . . . . . . . . . . . . . . . . 65
13.4 LaTeX content . . . . . . . . . . . . . . . . . . . . . . . . . 66
13.5 Linking with bookdown . . . . . . . . . . . . . . . . . . . 66
13.6 Contributing templates . . . . . . . . . . . . . . . . . . . . 66

14 Interactive Tutorials 67
14.1 Get started . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
14.2 Tutorial types . . . . . . . . . . . . . . . . . . . . . . . . . 67
14.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
14.3.1 Solutions . . . . . . . . . . . . . . . . . . . . . . . . 68
14.3.2 Hints . . . . . . . . . . . . . . . . . . . . . . . . . . 68
14.4 Quiz questions . . . . . . . . . . . . . . . . . . . . . . . . . 68
14.5 Videos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
14.6 Shiny components . . . . . . . . . . . . . . . . . . . . . . . 68
14.7 Navigation and progress tracking . . . . . . . . . . . . . . 69

IV Other Topics 71

15 Parameterized reports 75
15.1 Declaring parameters . . . . . . . . . . . . . . . . . . . . . 75
15.2 Using parameters . . . . . . . . . . . . . . . . . . . . . . . 75
15.3 Knitting with parameters . . . . . . . . . . . . . . . . . . . 75
15.3.1 The Knit button . . . . . . . . . . . . . . . . . . . . 75
15.3.2 Knit with custom parameters . . . . . . . . . . . . . 76
15.3.3 The interactive user interface . . . . . . . . . . . . . 76
15.4 Publishing . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

16 HTML Widgets 77
16.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
16.2 A widget example (sigma.js) . . . . . . . . . . . . . . . . . 77
16.2.1 File layout . . . . . . . . . . . . . . . . . . . . . . . 77
16.2.2 Dependencies . . . . . . . . . . . . . . . . . . . . . 77
xiv Contents

16.2.3 R binding . . . . . . . . . . . . . . . . . . . . . . . 78
16.2.4 JavaScript binding . . . . . . . . . . . . . . . . . . . 78
16.2.5 Demo . . . . . . . . . . . . . . . . . . . . . . . . . . 78
16.3 Creating your own widgets . . . . . . . . . . . . . . . . . . 78
16.3.1 Requirements . . . . . . . . . . . . . . . . . . . . . 78
16.3.2 Scaffolding . . . . . . . . . . . . . . . . . . . . . . . 78
16.3.3 Other packages . . . . . . . . . . . . . . . . . . . . 78
16.4 Widget sizing . . . . . . . . . . . . . . . . . . . . . . . . . 79
16.4.1 Specifying a sizing policy . . . . . . . . . . . . . . . 79
16.4.2 JavaScript resize method . . . . . . . . . . . . . . . 79
16.5 Advanced topics . . . . . . . . . . . . . . . . . . . . . . . . 79
16.5.1 Data transformation . . . . . . . . . . . . . . . . . . 79
16.5.2 Passing JavaScript functions . . . . . . . . . . . . . 80
16.5.3 Custom widget HTML . . . . . . . . . . . . . . . . 80
16.5.4 Create a widget without an R package . . . . . . . . 80

17 Document Templates 81
17.1 Template structure . . . . . . . . . . . . . . . . . . . . . . . 81
17.2 Supporting files . . . . . . . . . . . . . . . . . . . . . . . . 81
17.3 Custom Pandoc templates . . . . . . . . . . . . . . . . . . 81
17.4 Sharing your templates . . . . . . . . . . . . . . . . . . . . 82

18 Creating New Formats 83


18.1 Deriving from built-in formats . . . . . . . . . . . . . . . . 83
18.2 Fully custom formats . . . . . . . . . . . . . . . . . . . . . 83
18.3 Using a new format . . . . . . . . . . . . . . . . . . . . . . 83

19 Shiny Documents 85
19.1 Getting started . . . . . . . . . . . . . . . . . . . . . . . . . 85
19.2 Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . 85
19.2.1 ShinyApps.io . . . . . . . . . . . . . . . . . . . . . 85
19.2.2 Shiny Server / RStudio Connect . . . . . . . . . . . 86
19.3 Embedded Shiny apps . . . . . . . . . . . . . . . . . . . . 86
19.3.1 Inline applications . . . . . . . . . . . . . . . . . . . 86
19.3.2 External applications . . . . . . . . . . . . . . . . . 86
19.4 Shiny widgets . . . . . . . . . . . . . . . . . . . . . . . . . 86
19.4.1 The shinyApp() function . . . . . . . . . . . . . . . 86
19.4.2 Example: k-Means clustering . . . . . . . . . . . . . 87
19.4.3 Widget size and layout . . . . . . . . . . . . . . . . 87
19.5 Multiple pages . . . . . . . . . . . . . . . . . . . . . . . . . 87
Contents xv

19.6 Delayed rendering . . . . . . . . . . . . . . . . . . . . . . . 87


19.7 Output arguments for render functions . . . . . . . . . . . 87
19.7.1 A caveat . . . . . . . . . . . . . . . . . . . . . . . . 87
List of Tables

3.1 The possible values of the df_print option for the


html_document format. . . . . . . . . . . . . . . . . . . . . . 18
3.2 The options for paged HTML tables. . . . . . . . . . . . . . . 18
3.3 The possible values of the df_print option for the
pdf_document format. . . . . . . . . . . . . . . . . . . . . . 23
3.4 Available top-level YAML metadata variables for LaTeX out-
put. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.5 Markdown variants for some popular publishing systems. . 25

8.1 The currently supported reveal.js plugins. . . . . . . . . . . 51

15.1 Possible input types and the associated Shiny functions for pa-
rameterized reports. . . . . . . . . . . . . . . . . . . . . . . 76

16.1 Options that can be specified within a sizing policy. . . . . . 79

xvii
List of Figures

2.1 A minimal R Markdown example in RStudio. . . . . . . . . . 7


2.2 The output document of the minimal R Markdown example
in RStudio. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3 A screenshot of RPubs.com that contains some homework ass-
ginments submitted by students. . . . . . . . . . . . . . . . . 7
2.4 The output formats listed in the dropdown menu on the RStu-
dio toolbar. . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.5 Two plots side-by-side. . . . . . . . . . . . . . . . . . . . . . 10
2.6 The R Markdown hex logo. . . . . . . . . . . . . . . . . . . . 10
2.7 An R Markdown document with a leaflet map widget. . . . . 12
2.8 An R Markdown document with a Shiny widget. . . . . . . . 12

3.1 Traditional tabs and pill tabs on an HTML page. . . . . . . . 17


3.2 A paged table in the HTML output document. . . . . . . . . 18
3.3 An R Notebook example. . . . . . . . . . . . . . . . . . . . . 20
3.4 Send the R code chunk output to the console. . . . . . . . . . 20
3.5 Select the code to split into a new chunk. . . . . . . . . . . . 20
3.6 Insert a new chunk from the code selected before. . . . . . . 21
3.7 The indicator in the gutter to show the execution progress of
a code chunk in the notebook. . . . . . . . . . . . . . . . . . 21
3.8 Output from an inline R expression in the notebook. . . . . . 21
3.9 Execute a code chunk read from an external R script. . . . . . 22
3.10 Preview a notebook. . . . . . . . . . . . . . . . . . . . . . . 22
3.11 Errors in a notebook. . . . . . . . . . . . . . . . . . . . . . . 22

4.1 Two sample slides in an ioslides presentation. . . . . . . . . 27


4.2 Two sample slides in a Slidy presentation. . . . . . . . . . . 29
4.3 Two sample slides in a Beamer presentation. . . . . . . . . . 30
4.4 Two sample slides with the AnnArbor theme in Beamer. . . . 30
4.5 A sample slide in a PowerPoint presentation. . . . . . . . . . 31

5.1 A quick example of the dashboard layout. . . . . . . . . . . 37

xix
xx List of Figures

5.2 Multiple pages on a dashboard. . . . . . . . . . . . . . . . . 37


5.3 An example story board. . . . . . . . . . . . . . . . . . . . . 38
5.4 Three value boxes side by side on a dashboard. . . . . . . . . 38
5.5 Three gauges side by side on a dashboard. . . . . . . . . . . 38
5.6 Text annotations on a dashboard. . . . . . . . . . . . . . . . 39
5.7 An interactive dashboard based on Shiny. . . . . . . . . . . . 39

6.1 The basic layout of the Tufte style. . . . . . . . . . . . . . . . 41


6.2 A margin figure in the Tufte style. . . . . . . . . . . . . . . . 41
6.3 A full-width figure in the Tufte style. . . . . . . . . . . . . . 42
6.4 A figure in the main column in the Tufte style. . . . . . . . . 42
6.5 A table in the Tufte style. . . . . . . . . . . . . . . . . . . . . 42
6.6 The Tufte HTML style on narrow screens. . . . . . . . . . . . 43

7.1 Two sample slides created from the xaringan package. . . . . 45


7.2 Separate the current display from the external display. . . . . 46

8.1 Two sample slides created from the revealjs package. . . . . 49

9.1 The leonids theme of the prettydoc package. . . . . . . . . . 53


9.2 The Material Design theme in the rmdformats package. . . . 54
9.3 A few sample slides created via the Shower presentation
framework. . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

10.1 Knit a single page of a website. . . . . . . . . . . . . . . . . . 56


10.2 Build an entire website in RStudio. . . . . . . . . . . . . . . 56
10.3 Preview a page side-by-side with the editor in RStudio. . . . 56

11.1 A screenshot of the pkgdown website. . . . . . . . . . . . . . 59

12.1 The HTML output of the bookdown template. . . . . . . . . 61


12.2 The Build tab within RStudio highlighting bookdown output
formats. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

13.1 Two journal templates in the rticles package (PLOS and


Springer). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
13.2 The R Markdown template window in RStudio showing avail-
able rticles templates. . . . . . . . . . . . . . . . . . . . . . . 65

14.1 Create an interactive tutorial in RStudio. . . . . . . . . . . . 67


14.2 A simple example tutorial. . . . . . . . . . . . . . . . . . . . 67
14.3 A solution to an exercise. . . . . . . . . . . . . . . . . . . . . 68
List of Figures xxi

14.4 A question in a tutorial. . . . . . . . . . . . . . . . . . . . . . 68


14.5 Keeping track of the student’s progress in a tutorial. . . . . . 69

15.1 Input parameter values interactively for parameterized re-


ports. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
15.2 Custom controls for parameters. . . . . . . . . . . . . . . . . 76

16.1 A graph generated using the sigma.js library and the sigma
package. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

17.1 Selecting R Markdown templates within RStudio. . . . . . . 81

19.1 Create a new Shiny document in RStudio. . . . . . . . . . . . 85


19.2 Increase the number of rows in the table in a Shiny document. 85
19.3 Change the number of bins of a histogram in a Shiny docu-
ment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
19.4 Deploy a Shiny document to ShinyApps.io. . . . . . . . . . . 86
19.5 A Shiny widget to apply k-Means clustering on a dataset. . . 87
Preface

The document format “R Markdown” was first introduced in the knitr pack-
age (Xie, 2015, 2018) in early 2012. The idea was to embed code chunks (of R
or other languages) in Markdown documents. In fact, knitr supported sev-
eral authoring languages from the beginning in addition to Markdown, in-
cluding LaTeX, HTML, AsciiDoc, reStructuredText, and Textile. Looking back
over the five years, it seems to be fair to say that Markdown has become the
most popular document format, which is what we expected. The simplicity
of Markdown clearly stands out among these document formats.

However, the original version of Markdown invented by John Gruber1 was


often found overly simple and not suitable to write highly technical docu-
ments. For example, there was no syntax for tables, footnotes, math expres-
sions, or citations. Fortunately, John MacFarlane created a wonderful pack-
age named Pandoc (http://pandoc.org) to convert Markdown documents
(and many other types of documents) to a large variety of output formats.
More importantly, the Markdown syntax was significantly enriched. Now
we can write more types of elements with Markdown while still enjoying its
simplicity.

In a nutshell, R Markdown stands on the shoulders of knitr and Pandoc. The


former executes the computer code embedded in Markdown, and converts R
Markdown to Markdown. The latter renders Markdown to the output format
you want (such as PDF, HTML, Word, and so on).

The rmarkdown package (Allaire et al., 2018) was first created in early 2014.
During the past four years, it has steadily evolved into a relatively complete
ecosystem for authoring documents, so it is a good time for us to provide a
definitive guide to this ecosystem now. At this point, there are a large number
of tasks that you could do with R Markdown:

• Compile a single R Markdown document to a report in different formats,


such as PDF, HTML, or Word.
1
https://en.wikipedia.org/wiki/Markdown

xxiii
xxiv Preface

• Create notebooks in which you can directly run code chunks interactively.

• Make slides for presentations (HTML5, LaTeX Beamer, or PowerPoint).

• Produce dashboards with flexible, interactive, and attractive layouts.

• Build interactive applications based on Shiny.

• Write journal articles.

• Author books of multiple chapters.

• Generate websites and blogs.

There is a fundamental assumption underneath R Markdown that users


should be aware of: we assume it suffices that only a limited number of fea-
tures are supported in Markdown. By “features”, we mean the types of ele-
ments you can create with native Markdown. The limitation is a great feature,
not a bug. R Markdown may not be the right format for you if you find these
elements not enough for your writing: paragraphs, (section) headers, block
quotations, code blocks, (numbered and unnumbered) lists, horizontal rules,
tables, inline formatting (emphasis, strikeout, superscripts, subscripts, verba-
tim, and small caps text), LaTeX math expressions, equations, links, images,
footnotes, citations, theorems, proofs, and examples. We believe this list of
elements suffice for most technical and non-technical documents. It may not
be impossible to support other types of elements in R Markdown, but you
may start to lose the simplicity of Markdown if you wish to go that far.

Epictetus once said, “Wealth consists not in having great possessions, but in hav-
ing few wants.” The spirit is also reflected in Markdown. If you can control
your preoccupation with pursuing typesetting features, you should be much
more efficient in writing the content and can become a prolific author. It is
entirely possible to succeed with simplicity. Jung Jae-sung was a legendary
badminton player with a remarkably simple playing style: he did not look
like a talented player and was very short compared to other players, so most
of the time you would just see him jump three feet off the ground and smash
like thunder over and over again in the back court until he beats his oppo-
nents.

Please do not underestimate the customizability of R Markdown because of


the simplicity of its syntax. In particular, Pandoc templates can be surpris-
ingly powerful, as long as you understand the underlying technologies such
as LaTeX and CSS, and are willing to invest time in the appearance of your
output documents (reports, books, presentations, and/or websites). As one
Preface xxv

example, you may check out the PDF report2 of the 2017 Employer Health
Benefits Survey3 . It looks fairly sophisticated, but was actually produced via
bookdown (Xie, 2016), which is an R Markdown extension. A custom LaTeX
template and a lot of LaTeX tricks were used to generate this report. Not sur-
prisingly, this very book that you are reading right now was also written in R
Markdown, and its full source is publicly available in the GitHub repository
https://github.com/rstudio/rmarkdown-book.

R Markdown documents are often portable in the sense that they can be com-
piled to multiple types of output formats. Again, this is mainly due to the
simplified syntax of the authoring language, Markdown. The simpler the el-
ements in your document are, the more likely that the document can be con-
verted to different formats. Similarly, if you heavily tailor R Markdown to
a specific output format (e.g., LaTeX), you are likely to lose the portability,
because not all features in one format work in another format.

Last but not least, your computing results will be more likely to be repro-
ducible if you use R Markdown (or other knitr-based source documents),
compared to the manual cut-and-paste approach. This is because the results
are dynamically generated from computer source code. If anything goes
wrong or needs to be updated, you can simply fix or update the source code,
compile the document again, and the results will automatically updated. You
can enjoy reproducibility and convenience at the same time.

How to read this book


This book may serve you better as a reference book than a textbook. It con-
tains a large number of technical details, and we do not expect you to read
it from beginning to end, since you may easily feel overwhelmed. Instead,
think about your background and what you want to do first, and go to the
relevant chapters or sections. For example:

• I just want to finish my course homework (Chapter 2 should be more than


enough for you).
2
http://files.kff.org/attachment/Report-Employer-Health-Benefits-Annual-
Survey-2017
3
https://www.kff.org/health-costs/report/2017-employer-health-benefits-
survey/
xxvi Preface

• I know this is an R Markdown book, but I use Python more than R (Go
to Section 2.7.1).

• I want to embed interactive plots in my reports, or want my readers to be


able change my model parameters interactively and see results on the fly
(Check out Section 2.8).

• I know the output format I want to use, and I want to customize its ap-
pearance (Check out the documentation of the specific output format in
Chapter 3 or Chapter 4). For example, I want to customize the template
for my PowerPoint presentation (Go to Section 4.4.1).

• I want to build a business dashboard highlighting some key figures and


indicators (Go to Chapter 5).

• I heard about yolo = TRUE from a friend, and I’m curious what that means
in the xaringan package (Go to Chapter 7).

• I want to build a personal website (Go to Chapter 10), or write a book (Go
to Chapter 12).

• I want to write a paper and submit to the Journal of Statistical Software


(Go to Chapter 13).

• I want to build an interactive tutorial with exercises for my students to


learn a topic (Go to Chapter 14).

• I’m familiar with R Markdown now, and I want to generate personalized


reports for all my customers using the same R Markdown template (Try
parameterized reports in Chapter 15).

• I know some JavaScript, and want to build an interface in R to call an in-


terested JavaScript library from R (Learn how to develop HTML widgets
in Chapter 16).

• I want to build future reports with a company branded template that


shows our logo and uses our unique color theme (Go to Chapter 17).

If you are not familiar with R Markdown, we recommend that you read at
least Chapter 2 to learn the basics. All the rest of the chapters in this book
can be read in any order you desire. They are pretty much orthogonal to
each other. However, to become familiar with R Markdown output formats,
you may want to thumb through the HTML document format in Section 3.1,
because many other formats share the same options as this format.
Preface xxvii

Structure of the book


This book consists of four parts. Part I covers the basics: Chapter 1 introduces
how to install the relevant packages, and Chapter 2 is an overview of R Mark-
down, including the possible output formats, the Markdown syntax, the R
code chunk syntax, and how to use other languages in R Markdown.

Part II is the detailed documentation of built-in output formats in the rmark-


down package, including document formats and presentation formats.

Part III lists about ten R Markdown extensions that enable you to build dif-
ferent applications or generate output documents with different styles. Chap-
ter 5 introduces the basics of building flexible dashboards with the R pack-
age flexdashboard. Chapter 6 documents the tufte package, which provides
a unique document style used by Edward Tufte. Chapter 7 introduces the
xaringan package for another highly flexible and customizable HTML5 pre-
sentation format based on the JavaScript library remark.js. Chapter 8 docu-
ments the revealjs package, which provides yet another appealing HTML5
presentation format based on the JavaScript library reveal.js. Chapter 9 intro-
duces a few output formats created by the R community, such as the pretty-
doc package, which features lightweight HTML document formats. Chapter
10 teaches you how to build websites using either the blogdown package
or rmarkdown’s built-in site generator. Chapter 11 explains the basics of the
pkgdown package, which can be used to quickly build documentation web-
sites for R packages. Chapter 12 introduces how to write and publish books
with the bookdown package. Chapter 13 is an overview of the rticles package
for authoring journal articles. Chapter 14 introduces how to build interactive
tutorials with exercises and/or quiz questions.

Part IV covers other topics about R Markdown, and some of them are ad-
vanced (in particular, Chapter 16). Chapter 15 introduces how to generate dif-
ferent reports with the same R Markdown source document and different pa-
rameters. Chapter 16 teaches developers how to build their own HTML wid-
gets for interactive visualization and applications with JavaScript libraries.
Chapter 17 shows how to create custom R Markdown and Pandoc templates
so that you can fully customize the appearance and style of your output doc-
ument. Chapter 18 explains how to create your own output formats if the
existing formats do not meet your need. Chapter 19 shows how to combine
the Shiny framework with R Markdown, so that your readers can interact
xxviii Preface

with the reports by changing the values of certain input widgets and seeing
updated results immediately.

Note that this book is intended to be a guide instead of the comprehensive


documentation of all topics related to R Markdown. Some chapters are only
overviews, and you may need to consult the full documentation elsewhere
(often freely available online). Such examples include Chapters 5, 10, 11, 12,
and 14.

Software information and conventions


The R session information when compiling this book is shown below:

xfun::session_info(c(
'blogdown', 'bookdown', 'knitr', 'rmarkdown', 'htmltools',
'reticulate', 'rticles', 'flexdashboard', 'learnr', 'shiny',
'revealjs', 'pkgdown', 'tinytex', 'xaringan', 'tufte'
), dependencies = FALSE)

## R version 3.5.1 (2018-07-02)


## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS 10.14.2
##
## Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-
8 / en_US.UTF-8
##
## Package version:
## blogdown_0.9.8 bookdown_0.8.2
## flexdashboard_0.5.1.1 htmltools_0.3.6
## knitr_1.21.4 learnr_0.9.2.1
## pkgdown_1.3.0 reticulate_1.10
## revealjs_0.9 rmarkdown_1.11
## rticles_0.6 shiny_1.2.0
## tinytex_0.9.3 tufte_0.4
## xaringan_0.8.4
##
## Pandoc version: 2.3.1
Preface xxix

We do not add prompts (> and +) to R source code in this book, and we
comment out the text output with two hashes ## by default, as you can
see from the R session information above. This is for your convenience
when you want to copy and run the code (the text output will be ignored
since it is commented out). Package names are in bold text (e.g., rmark-
down), and inline code and filenames are formatted in a typewriter font
(e.g., knitr::knit('foo.Rmd')). Function names are followed by parenthe-
ses (e.g., blogdown::serve_site()). The double-colon operator :: means ac-
cessing an object from a package.

“Rmd” is the filename extension of R Markdown files, and also an abbrevia-


tion of R Markdown in this book.

Acknowledgments
I started writing this book after I came back from the 2018 RStudio Confer-
ence in early February, and finished the first draft in early May. This may
sound fast for a 300-page book. The main reason I was able to finish it quickly
was that I worked full-time on this book for three months. My employer,
RStudio, has always respected my personal interests and allowed me to fo-
cus on projects that I choose by myself. More importantly, I have been taught
several lessons on how to become a professional software engineer since I
joined RStudio as a fresh PhD, although the initial journey turned out to be
painful.4 It is a great blessing for me to work in this company.

The other reason for my speed was that JJ and Garrett had already prepared
a lot of materials that I could adapt for this book. They had also been offering
suggestions as I worked on the manuscript. In addition, Michael Harper5 con-
tributed the initial drafts of Chapters 12, 13, 15, 17, and 18. I would definitely
not be able to finish this book so quickly without their help.

The most challenging thing to do when writing a book is to find large blocks
of uninterrupted time. This is just so hard. Both others and myself could in-
terrupt me. I do not consider my willpower to be strong: I read random ar-
ticles, click on the endless links on Wikipedia, look at random Twitter mes-
sages, watch people fight on meaningless topics online, reply to emails all
4
https://yihui.name/en/2018/02/career-crisis/
5
http://mikeyharper.uk
xxx Preface

the time as if I were able to reach “Inbox Zero”, and write random blog posts
from time to time. The two most important people in terms of helping keep
me on track are Tareef Kawaf (President of RStudio), to whom I report my
progress on the weekly basis, and Xu Qin6 , from whom I really learned7
the importance of making plans on a daily basis (although I still fail to do
so sometimes). For interruptions from other people, it is impossible to iso-
late myself from the outside world, so I’d like to thank those who did not
email me or ask me questions in the past few months and used public chan-
nels instead as I suggested8 . I also thank those who did not get mad at me
when my responses were extremely slow or even none. I appreciate all your
understanding and patience. Besides, several users have started helping me
answer GitHub and Stack Overflow questions related to R packages that I
maintain, which is even better! These users include Marcel Schilling9 , Xiany-
ing Tan10 , Christophe Dervieux11 , and Garrick Aden-Buie12 , just to name a
few. As someone who works from home, apparently I would not even have
ten minutes of uninterrupted time if I do not send the little ones to daycare,
so I want to thank all teachers at Small Miracles for freeing my daytime.

There have been a large number of contributors to the R Markdown ecosys-


tem. More than 60 people13 have contributed to the core package, rmark-
down. Several authors have created their own R Markdown extensions, as
introduced in Part III of this book. Contributing ideas is no less helpful than
contributing code. We have gotten numerous inspirations and ideas from the
R community via various channels (GitHub issues, Stack Overflow questions,
and private conversations, etc.). As a small example, Jared Lander, author of
the book R for Everyone, does not meet me often, but every time he chats with
me, I will get something valuable to work on. “How about writing books with
R Markdown?” he asked me at the 2014 Strata conference in New York. Then
we invented bookdown in 2016. “I really need fullscreen background images
in ioslides. Look, Yihui, here are my ugly JavaScript hacks,14 ” he showed me
on the shuttle to dinner at the 2017 RStudio Conference. A year later, back-
ground images were officially supported in ioslides presentations.
6
http://home.uchicago.edu/~xuqin/
7
https://d.cosx.org/d/419325
8
https://yihui.name/en/2017/08/so-gh-email/
9
https://yihui.name/en/2018/01/thanks-marcel-schilling/
10
https://shrektan.com
11
https://github.com/cderv
12
https://www.garrickadenbuie.com
13
https://github.com/rstudio/rmarkdown/graphs/contributors
14
https://www.jaredlander.com/2017/07/fullscreen-background-images-in-
ioslides-presentations/
Preface xxxi

As I mentioned previously, R Markdown is standing on the shoulders of the


giant, Pandoc. I’m always amazed by how fast John MacFarlane, the main au-
thor of Pandoc, responds to my GitHub issues. It is hard to imagine a person
dealing with 5000 GitHub issues15 over the years while maintaining the ex-
cellent open-source package and driving the Markdown standards forward.
We should all be grateful to John and contributors of Pandoc.

As I was working on the draft of this book, I received a lot of helpful re-
views from these reviewers: John Gillett (University of Wisconsin), Rose Hart-
man (UnderstandingData), Amelia McNamara (Smith College), Ariel Mul-
doon (Oregon State University), Yixuan Qiu (Purdue University), Benjamin
Soltoff (University of Chicago), David Whitney (University of Washington),
and Jon Katz (independent data analyst). Tareef Kawaf (RStudio) also volun-
teered to read the manuscript and provided many helpful comments. Aaron
Simumba16 , Peter Baumgartner17 , and Daijiang Li18 volunteered to carefully
correct many of my typos. In particular, Aaron has been such a big helper
with my writing (not limited to only this book) and sometimes I have to com-
pete with him19 in correcting my typos!

There are many colleagues at RStudio whom I want to thank for making it so
convenient and even enjoyable to author R Markdown documents, especially
the RStudio IDE team including J.J. Allaire, Kevin Ushey, Jonathan McPher-
son, and many others.

Personally I often feel motivated by members of the R community. My own


willpower is weak, but I can gain a lot of power from this amazing commu-
nity. Overall the community is very encouraging, and sometimes even fun,
which makes me enjoy my job. For example, I do not think you can often use
the picture of a professor for fun in your software, but the “desiccated baseR-
er”20 Karl Broman is an exception (see Section 7.3.6), as he allowed me to use
a mysteriously happy picture of him.

Lastly, I want to thank my editor, John Kimmel, for his continued help with
my fourth book. I think I have said enough about him and his team at Chap-
man & Hall in my previous books. The publishing experience has always
been so smooth. I just wonder if it would be possible someday that our metic-
15
https://github.com/jgm/pandoc
16
https://asimumba.rbind.io
17
http://peter.baumgartner.name
18
https://daijiang.name
19
https://github.com/rbind/yihui/commit/d8f39f7aa
20
https://twitter.com/kwbroman/status/922545181634768897
xxxii Preface

ulous copy-editor, Suzanne Lassandro, would fail to identify more than 30


issues for me to correct in my first draft. Probably not. Let’s see.

Yihui Xie
Elkhorn, Nebraska
About the Authors

This book is primarily put together by me (Yihui Xie), making use of the exist-
ing R documentation of the rmarkdown package and the rmarkdown web-
site, which were mainly contributed by J.J. Allaire and Garrett Grolemund.

Yihui Xie
Yihui Xie (https://yihui.name) is a software engineer at RStudio (https:
//www.rstudio.com). He earned his PhD from the Department of Statistics,
Iowa State University. He is interested in interactive statistical graphics and
statistical computing. As an active R user, he has authored several R pack-
ages, such as knitr, bookdown, blogdown, xaringan, tinytex, animation,
DT, tufte, formatR, fun, xfun, mime, highr, servr, and Rd2roxygen, among
which the animation package won the 2009 John M. Chambers Statistical
Software Award (ASA). He also co-authored a few other R packages, includ-
ing shiny, rmarkdown, and leaflet.

He has authored two books, Dynamic Documents with knitr (Xie, 2015), and
bookdown: Authoring Books and Technical Documents with R Markdown (Xie,
2016), and co-authored two book, blogdown: Creating Websites with R Mark-
down (Xie et al., 2017), and R Markdown: The Definitive Guide (Xie et al., 2018).

In 2006, he founded the Capital of Statistics (https://cosx.org), which has


grown into a large online community on statistics in China. He initiated the
Chinese R conference in 2008, and has been involved in organizing R con-
ferences in China since then. During his PhD training at Iowa State Univer-
sity, he won the Vince Sposito Statistical Computing Award (2011) and the
Snedecor Award (2012) in the Department of Statistics.

He occasionally rants on Twitter (https://twitter.com/xieyihui), and


most of the time you can find him on GitHub (https://github.com/yihui).

xxxiii
xxxiv About the Authors

He enjoys spicy food as much as classical Chinese literature.

J.J. Allaire
J.J. Allaire is the founder of RStudio and the creator of the RStudio IDE. J.J.
is an author of several packages in the R Markdown ecosystem including
rmarkdown, flexdashboard, learnr, and radix.

Garrett Grolemund
Garrett Grolemund is the co-author of R for Data Science and author of Hands-
On Programming with R. He wrote the lubridate R package and works for
RStudio as an advocate who trains engineers to do data science with R and
the Tidyverse. If you use R yourself, you may recognize Garrett from his
video courses on Datacamp.com and O’Reilly media, or for his series of pop-
ular R cheatsheets distributed by RStudio.

Garrett earned his PhD in Statistics from Rice University in 2012 under the
guidance of Hadley Wickham. Before that, he earned a Bachelor’s degree in
Psychology from Harvard University and briefly attended law school. Gar-
rett has been one of the foremost promoters of Shiny, R Markdown, and the
Tidyverse, documenting and explaining each in detail.
Part I

Get Started
0.0 3

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
1
Installation

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

5
2
Basics

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 2.1: A minimal R Markdown example in RStudio.

FIGURE 2.2: The output document of the minimal R Markdown example in


RStudio.

2.1 Example applications


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.1.1 Airbnb’s knowledge repository


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.1.2 Homework assignments on RPubs


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 2.3: A screenshot of RPubs.com that contains some homework ass-


ginments submitted by students.

7
8 2 Basics

2.1.3 Personalized mail


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.1.4 2017 Employer Health Benefits Survey


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.1.5 Journal articles


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.1.6 Dashboards at eelloo


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.1.7 Books
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.1.8 Websites
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.2 Compile an R Markdown document


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
2.6 Cheat sheets 9

2.3 Cheat sheets


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.4 Output formats


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 2.4: The output formats listed in the dropdown menu on the RStu-
dio toolbar.

2.5 Markdown syntax


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.5.1 Inline formatting


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.5.2 Block-level elements


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.5.3 Math expressions


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
10 2 Basics

2.6 R code chunks and inline R code


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.6.1 Figures
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 2.5: Two plots side-by-side.

FIGURE 2.6: The R Markdown hex logo.

2.6.2 Tables
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.7 Other language engines


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.7.1 Python
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.7.2 Shell scripts


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
2.8 Interactive documents 11

2.7.3 SQL
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.7.4 Rcpp
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.7.5 Stan
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.7.6 JavaScript and CSS


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.7.7 Julia
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.7.8 C and Fortran


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.8 Interactive documents


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

2.8.1 HTML widgets


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
12 2 Basics

FIGURE 2.7: An R Markdown document with a leaflet map widget.

2.8.2 Shiny documents


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 2.8: An R Markdown document with a Shiny widget.


Part II

Output Formats
2.8 15

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
3
Documents

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1 HTML document


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.1 Table of contents


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.1.1 Floating TOC

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.2 Section numbering


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.3 Tabbed sections


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 3.1: Traditional tabs and pill tabs on an HTML page.

17
18 3 Documents

TABLE 3.1: The possible values of the df_print option for the
html_document format.

TABLE 3.2: The options for paged HTML tables.

3.1.4 Appearance and style


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.4.1 Custom CSS

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.5 Figure options


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.6 Data frame printing


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.6.1 Paged printing

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 3.2: A paged table in the HTML output document.

3.1.7 Code folding


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
3.1 HTML document 19

3.1.8 MathJax equations


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.9 Document dependencies


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.10 Advanced customization


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.10.1 Keeping Markdown

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.10.2 Includes

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.10.3 Custom templates

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.10.4 Markdown extensions

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.10.5 Pandoc arguments

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.1.11 Shared options


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
20 3 Documents

3.1.12 HTML fragments


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.2 Notebook
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 3.3: An R Notebook example.

3.2.1 Using Notebooks


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.2.1.1 Creating a Notebook

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 3.4: Send the R code chunk output to the console.

3.2.1.2 Inserting chunks

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 3.5: Select the code to split into a new chunk.

3.2.1.3 Executing code

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
3.2 Notebook 21

FIGURE 3.6: Insert a new chunk from the code selected before.

FIGURE 3.7: The indicator in the gutter to show the execution progress of a
code chunk in the notebook.

3.2.1.4 Chunk output

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.2.2 Saving and sharing


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.2.2.1 Notebook file

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.2.2.2 Output storage

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.2.2.3 Version control

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.2.3 Notebook format


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.2.3.1 Generating R Notebooks with custom output

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 3.8: Output from an inline R expression in the notebook.


22 3 Documents

FIGURE 3.9: Execute a code chunk read from an external R script.

FIGURE 3.10: Preview a notebook.

3.2.3.2 Implementing output sources

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.2.3.3 Parsing R Notebooks

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.3 PDF document


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.3.1 Table of contents


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.3.2 Figure options


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.3.3 Data frame printing


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 3.11: Errors in a notebook.


3.3 PDF document 23

TABLE 3.3: The possible values of the df_print option for the pdf_document
format.

TABLE 3.4: Available top-level YAML metadata variables for LaTeX output.

3.3.4 Syntax highlighting


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.3.5 LaTeX options


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.3.6 LaTeX packages for citations


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.3.7 Advanced customization


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.3.7.1 LaTeX engine

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.3.7.2 Keeping intermediate TeX

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.3.7.3 Includes

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
24 3 Documents

3.3.7.4 Custom templates

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.3.8 Other features


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.4 Word document


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.4.1 Other features


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.5 OpenDocument Text document


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.5.1 Other features


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.6 Rich Text Format document


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
3.8 Markdown document 25

TABLE 3.5: Markdown variants for some popular publishing systems.

3.6.1 Other features


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.7 Markdown document


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.7.1 Markdown variants


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.7.1.1 Publishing formats

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.7.2 Other features


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

3.8 R package vignette


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
4
Presentations

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.1 ioslides presentation


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 4.1: Two sample slides in an ioslides presentation.

4.1.1 Display modes


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.1.2 Incremental bullets


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.1.3 Visual appearance


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.1.3.1 Presentation size

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

27
28 4 Presentations

4.1.3.2 Transition speed

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.1.3.3 Build slides

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.1.3.4 Background images

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.1.3.5 Custom CSS

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.1.4 Code highlighting


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.1.5 Adding a logo


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.1.6 Tables
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.1.7 Advanced layout


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.1.8 Text color


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
4.2 Slidy presentation 29

4.1.9 Presenter mode


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.1.10 Printing and PDF output


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.1.11 Custom templates


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.1.12 Other features


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.2 Slidy presentation


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 4.2: Two sample slides in a Slidy presentation.

4.2.1 Display modes


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.2.2 Text size


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
30 4 Presentations

4.2.3 Footer elements


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.2.4 Other features


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.3 Beamer presentation


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 4.3: Two sample slides in a Beamer presentation.

4.3.1 Themes
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 4.4: Two sample slides with the AnnArbor theme in Beamer.

4.3.2 Slide level


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.3.3 Other features


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
4.4 PowerPoint presentation 31

4.4 PowerPoint presentation


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 4.5: A sample slide in a PowerPoint presentation.

4.4.1 Custom templates


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

4.4.2 Other features


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
Part III

Extensions
4.4 35

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
5
Dashboards

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

5.1 Layout
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 5.1: A quick example of the dashboard layout.

5.1.1 Row-based layouts


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

5.1.2 Attributes on sections


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

5.1.3 Multiple pages


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 5.2: Multiple pages on a dashboard.

37
38 5 Dashboards

5.1.4 Story boards


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 5.3: An example story board.

5.2 Components
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

5.2.1 Value boxes


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 5.4: Three value boxes side by side on a dashboard.

5.2.2 Gauges
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 5.5: Three gauges side by side on a dashboard.

5.2.3 Text annotations


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

5.2.4 Navigation bar


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
5.3 Shiny 39

FIGURE 5.6: Text annotations on a dashboard.

5.3 Shiny
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

5.3.1 Getting started


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

5.3.2 A Shiny dashboard example


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 5.7: An interactive dashboard based on Shiny.

5.3.3 Input sidebar


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

5.3.4 Learning more


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
6
Tufte Handouts

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 6.1: The basic layout of the Tufte style.

6.1 Headings
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

6.2 Figures
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

6.2.1 Margin figures


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 6.2: A margin figure in the Tufte style.

6.2.2 Arbitrary margin content


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

41
42 6 Tufte Handouts

6.2.3 Full-width figures


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 6.3: A full-width figure in the Tufte style.

6.2.4 Main column figures


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 6.4: A figure in the main column in the Tufte style.

6.3 Sidenotes
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

6.4 References
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

6.5 Tables
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 6.5: A table in the Tufte style.


6.9 Block quotes 43

6.6 Block quotes


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

6.7 Responsiveness
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 6.6: The Tufte HTML style on narrow screens.

6.8 Sans-serif fonts and epigraphs


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

6.9 Customize CSS styles


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
7
xaringan Presentations

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 7.1: Two sample slides created from the xaringan package.

7.1 Get started


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

7.2 Keyboard shortcuts


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

7.3 Slide formatting


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

7.3.1 Slides and properties


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

45
46 7 xaringan Presentations

7.3.2 The title slide


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

7.3.3 Content classes


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

7.3.4 Incremental slides


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

7.3.5 Presenter notes


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 7.2: Separate the current display from the external display.

7.3.6 yolo: true


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

7.4 Build and preview slides


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

7.5 CSS and themes


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
7.6 Some tips 47

7.6 Some tips


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

7.6.1 Autoplay slides


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

7.6.2 Countdown timer


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

7.6.3 Highlight code lines


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

7.6.4 Working offline


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

7.6.5 Macros
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

7.6.6 Disadvantages
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
8
reveal.js Presentations

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 8.1: Two sample slides created from the revealjs package.

8.1 Display modes


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

8.2 Appearance and style


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

8.2.1 Smaller text


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

8.3 Slide transitions


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

49
50 8 reveal.js Presentations

8.4 Slide backgrounds


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

8.5 2-D presentations


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

8.6 Custom CSS


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

8.6.1 Slide IDs and classes


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

8.6.2 Styling text spans


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

8.7 reveal.js options


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
8.9 reveal.js plugins 51

TABLE 8.1: The currently supported reveal.js plugins.

8.8 reveal.js plugins


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

8.9 Other features


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
9
Community Formats

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

9.1 Lightweight Pretty HTML Documents


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

9.1.1 Usage
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 9.1: The leonids theme of the prettydoc package.

9.1.2 Package vignettes


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

9.2 The rmdformats package


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

53
54 9 Community Formats

FIGURE 9.2: The Material Design theme in the rmdformats package.

9.3 Shower presentations


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 9.3: A few sample slides created via the Shower presentation frame-
work.
10
Websites

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.1 Get started


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.2 The directory structure


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.3 Deployment
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.4 Other site generators


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

55
56 10 Websites

10.5 rmarkdown’s site generator


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.1 A simple example


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.2 Site authoring


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.2.1 RStudio

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 10.1: Knit a single page of a website.

FIGURE 10.2: Build an entire website in RStudio.

FIGURE 10.3: Preview a page side-by-side with the editor in RStudio.

10.5.2.2 Command line

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.2.3 knitr caching

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
10.5 rmarkdown’s site generator 57

10.5.3 Common elements


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.3.1 Content

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.3.2 R scripts

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.3.3 Rmd partials

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.4 Site navigation


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.4.1 HTML navigation bar

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.5 HTML generation


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.5.1 The htmltools package

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.6 Site configuration


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
58 10 Websites

10.5.6.1 Included files

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.7 Publishing websites


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.8 Additional examples


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.9 Custom site generators


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.9.1 Site generator function

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

10.5.9.2 Examples

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
11
HTML Documentation for R Packages

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 11.1: A screenshot of the pkgdown website.

11.1 Get started


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

11.2 Components
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

11.2.1 Home page


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

11.2.2 Function reference


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

59
60 11 HTML Documentation for R Packages

11.2.3 Articles
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

11.2.4 News
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

11.2.5 Navigation bar


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
12
Books

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.1 Get started


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 12.1: The HTML output of the bookdown template.

12.2 Project structure


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.2.1 Index file


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.2.2 Rmd files


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

61
62 12 Books

12.2.3 _bookdown.yml

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.2.4 _output.yml

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.3 Markdown extensions


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.3.1 Number and reference equations


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.3.2 Theorems and proofs


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.3.3 Special headers


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.3.4 Text references


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.3.5 Cross referencing


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
12.5 Output Formats 63

12.4 Output Formats


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.4.1 HTML
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.4.2 LaTeX/PDF
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.4.3 E-books
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.4.4 A single document


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.5 Editing
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.5.1 Build the book


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
64 12 Books

FIGURE 12.2: The Build tab within RStudio highlighting bookdown output
formats.

12.5.2 Preview a chapter


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.5.3 Serve the book


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.5.4 RStudio addins


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.6 Publishing
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.6.1 RStudio Connect


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.6.2 Other services


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

12.6.3 Publishers
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
13
Journals

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 13.1: Two journal templates in the rticles package (PLOS and
Springer).

13.1 Get started


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 13.2: The R Markdown template window in RStudio showing avail-


able rticles templates.

13.2 rticles templates


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

13.3 Using a template


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

65
66 13 Journals

13.4 LaTeX content


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

13.5 Linking with bookdown


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

13.6 Contributing templates


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
14
Interactive Tutorials

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

14.1 Get started


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 14.1: Create an interactive tutorial in RStudio.

FIGURE 14.2: A simple example tutorial.

14.2 Tutorial types


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

14.3 Exercises
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

67
68 14 Interactive Tutorials

14.3.1 Solutions
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 14.3: A solution to an exercise.

14.3.2 Hints
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

14.4 Quiz questions


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 14.4: A question in a tutorial.

14.5 Videos
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

14.6 Shiny components


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
14.7 Navigation and progress tracking 69

14.7 Navigation and progress tracking


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 14.5: Keeping track of the student’s progress in a tutorial.


Part IV

Other Topics
14.7 73

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
15
Parameterized reports

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

15.1 Declaring parameters


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

15.2 Using parameters


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

15.3 Knitting with parameters


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

15.3.1 The Knit button


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

75
76 15 Parameterized reports

TABLE 15.1: Possible input types and the associated Shiny functions for pa-
rameterized reports.

15.3.2 Knit with custom parameters


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

15.3.3 The interactive user interface


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 15.1: Input parameter values interactively for parameterized re-


ports.

FIGURE 15.2: Custom controls for parameters.

15.4 Publishing
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
16
HTML Widgets

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.1 Overview
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.2 A widget example (sigma.js)


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 16.1: A graph generated using the sigma.js library and the sigma
package.

16.2.1 File layout


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.2.2 Dependencies
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

77
78 16 HTML Widgets

16.2.3 R binding
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.2.4 JavaScript binding


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.2.5 Demo
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.3 Creating your own widgets


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.3.1 Requirements
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.3.2 Scaffolding
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.3.3 Other packages


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
16.5 Widget sizing 79

TABLE 16.1: Options that can be specified within a sizing policy.

16.4 Widget sizing


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.4.1 Specifying a sizing policy


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.4.2 JavaScript resize method


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.5 Advanced topics


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.5.1 Data transformation


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.5.1.1 HTMLWidgets.dataframeToD3()

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.5.1.2 HTMLWidgets.transposeArray2D()

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
80 16 HTML Widgets

16.5.1.3 Custom JSON serializer

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.5.2 Passing JavaScript functions


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.5.3 Custom widget HTML


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

16.5.4 Create a widget without an R package


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
17
Document Templates

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 17.1: Selecting R Markdown templates within RStudio.

17.1 Template structure


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

17.2 Supporting files


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

17.3 Custom Pandoc templates


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

81
82 17 Document Templates

17.4 Sharing your templates


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
18
Creating New Formats

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

18.1 Deriving from built-in formats


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

18.2 Fully custom formats


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

18.3 Using a new format


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

83
19
Shiny Documents

This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

19.1 Getting started


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 19.1: Create a new Shiny document in RStudio.

FIGURE 19.2: Increase the number of rows in the table in a Shiny document.

FIGURE 19.3: Change the number of bins of a histogram in a Shiny docu-


ment.

19.2 Deployment
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

19.2.1 ShinyApps.io
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

85
86 19 Shiny Documents

FIGURE 19.4: Deploy a Shiny document to ShinyApps.io.

19.2.2 Shiny Server / RStudio Connect


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

19.3 Embedded Shiny apps


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

19.3.1 Inline applications


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

19.3.2 External applications


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

19.4 Shiny widgets


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

19.4.1 The shinyApp() function


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
19.7 Multiple pages 87

19.4.2 Example: k-Means clustering


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

FIGURE 19.5: A Shiny widget to apply k-Means clustering on a dataset.

19.4.3 Widget size and layout


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

19.5 Multiple pages


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

19.6 Delayed rendering


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

19.7 Output arguments for render functions


This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.

19.7.1 A caveat
This PDF is only a skeleton. Please either read the free online HTML version,
or purchase a hard-copy of this book.
Bibliography

Allaire, J., Xie, Y., McPherson, J., Luraschi, J., Ushey, K., Atkins, A., Wickham,
H., Cheng, J., Chang, W., and Iannone, R. (2018). rmarkdown: Dynamic Doc-
uments for R. R package version 1.11.

Xie, Y. (2015). Dynamic Documents with R and knitr. Chapman and Hall/CRC,
Boca Raton, Florida, 2nd edition. ISBN 978-1498716963.

Xie, Y. (2016). bookdown: Authoring Books and Technical Documents with R


Markdown. Chapman and Hall/CRC, Boca Raton, Florida. ISBN 978-
1138700109.

Xie, Y. (2018). knitr: A General-Purpose Package for Dynamic Report Generation in


R. R package version 1.21.4.

Xie, Y., Allaire, J., and Grolemund, G. (2018). R Markdown: The Definitive Guide.
Chapman and Hall/CRC, Boca Raton, Florida. ISBN 9781138359338.

Xie, Y., Hill, A. P., and Thomas, A. (2017). blogdown: Creating Websites with
R Markdown. Chapman and Hall/CRC, Boca Raton, Florida. ISBN 978-
0815363729.

89

You might also like