Skip to main content
R Markdown: The Definitive Guide
A PreTeXt Edition
Yihui Xie, J. J. Allaire, Garrett Grolemund
Contents
Index
Search Book
close
Search Results:
No results.
Dark Mode
Prev
Up
Next
\(\require{cancel} \newcommand{\lt}{<} \newcommand{\gt}{>} \newcommand{\amp}{&} \definecolor{fillinmathshade}{gray}{0.9} \newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}} \)
Front Matter
Preface
How to read this book
Structure of the book
Software information and conventions
Acknowledgments
Note on This PreTeXt Edition
About the Authors
Yihui Xie
J.J. Allaire
Garrett Grolemund
I
Get Started
1
Installation
2
Basics
2.1
Example applications
2.1.1
Airbnb’s knowledge repository
2.1.2
Homework assignments on RPubs
2.1.3
Personalized mail
2.1.4
2017 Employer Health Benefits Survey
2.1.5
Journal articles
2.1.6
Dashboards at eelloo
2.1.7
Books
2.1.8
Websites
2.2
Compile an R Markdown document
2.3
Cheat sheets
2.4
Output formats
2.5
Markdown syntax
2.5.1
Inline formatting
2.5.2
Block-level elements
2.5.3
Math expressions
2.6
R code chunks and inline R code
2.6.1
Figures
2.6.2
Tables
2.7
Other language engines
2.7.1
Python
2.7.2
Shell scripts
2.7.3
SQL
2.7.4
Rcpp
2.7.5
Stan
2.7.6
JavaScript and CSS
2.7.7
Julia
2.7.8
C and Fortran
2.8
Interactive documents
2.8.1
HTML widgets
2.8.2
Shiny documents
II
Output Formats
3
Documents
3.1
HTML document
3.1.1
Table of contents
3.1.1.1
Floating TOC
3.1.2
Section numbering
3.1.3
Tabbed sections
3.1.4
Appearance and style
3.1.4.1
Custom CSS
3.1.5
Figure options
3.1.6
Data frame printing
3.1.6.1
Paged printing
3.1.6.2
Custom function
3.1.7
Code folding
3.1.8
MathJax equations
3.1.9
Document dependencies
3.1.10
Advanced customization
3.1.10.1
Keeping Markdown
3.1.10.2
Includes
3.1.10.3
Custom templates
3.1.10.4
Markdown extensions
3.1.10.5
Pandoc arguments
3.1.11
Shared options
3.1.12
HTML fragments
3.2
Notebook
3.2.1
Using Notebooks
3.2.1.1
Creating a Notebook
3.2.1.2
Inserting chunks
3.2.1.3
Executing code
3.2.1.4
Chunk output
3.2.2
Saving and sharing
3.2.2.1
Notebook file
3.2.2.2
Output storage
3.2.2.3
Version control
3.2.3
Notebook format
3.2.3.1
Generating R Notebooks with custom output
3.2.3.2
Implementing output sources
3.2.3.3
Parsing R Notebooks
3.3
PDF document
3.3.1
Table of contents
3.3.2
Figure options
3.3.3
Data frame printing
3.3.4
Syntax highlighting
3.3.5
LaTeX options
3.3.6
LaTeX packages for citations
3.3.7
Advanced customization
3.3.7.1
LaTeX engine
3.3.7.2
Keeping intermediate TeX
3.3.7.3
Includes
3.3.7.4
Custom templates
3.3.8
Other features
3.4
Word document
3.4.1
Other features
3.5
OpenDocument Text document
3.5.1
Other features
3.6
Rich Text Format document
3.6.1
Other features
3.7
Markdown document
3.7.1
Markdown variants
3.7.1.1
Publishing formats
3.7.2
Other features
3.8
R package vignette
4
Presentations
4.1
ioslides presentation
4.1.1
Display modes
4.1.2
Incremental bullets
4.1.3
Visual appearance
4.1.3.1
Presentation size
4.1.3.2
Transition speed
4.1.3.3
Build slides
4.1.3.4
Background images
4.1.3.5
Custom CSS
4.1.4
Code highlighting
4.1.5
Adding a logo
4.1.6
Tables
4.1.7
Advanced layout
4.1.8
Text color
4.1.9
Presenter mode
4.1.10
Printing and PDF output
4.1.11
Custom templates
4.1.12
Other features
4.2
Slidy presentation
4.2.1
Display modes
4.2.2
Text size
4.2.3
Footer elements
4.2.4
Other features
4.3
Beamer presentation
4.3.1
Themes
4.3.2
Slide level
4.3.3
Other features
4.4
PowerPoint presentation
4.4.1
Custom templates
4.4.2
Other features
III
Extensions
5
Dashboards
5.1
Layout
5.1.1
Row-based layouts
5.1.2
Attributes on sections
5.1.3
Multiple pages
5.1.4
Story boards
5.2
Components
5.2.1
Value boxes
5.2.2
Gauges
5.2.3
Text annotations
5.2.4
Navigation bar
5.3
Shiny
5.3.1
Getting started
5.3.2
A Shiny dashboard example
5.3.3
Input sidebar
5.3.4
Learning more
6
Tufte Handouts
6.1
Headings
6.2
Figures
6.2.1
Margin figures
6.2.2
Arbitrary margin content
6.2.3
Full-width figures
6.2.4
Main column figures
6.3
Sidenotes
6.4
References
6.5
Tables
6.6
Block quotes
6.7
Responsiveness
6.8
Sans-serif fonts and epigraphs
6.9
Customize CSS styles
7
xaringan Presentations
7.1
Get started
7.2
Keyboard shortcuts
7.3
Slide formatting
7.3.1
Slides and properties
7.3.2
The title slide
7.3.3
Content classes
7.3.4
Incremental slides
7.3.5
Presenter notes
7.3.6
yolo: true
7.4
Build and preview slides
7.5
CSS and themes
7.6
Some tips
7.6.1
Autoplay slides
7.6.2
Countdown timer
7.6.3
Highlight code lines
7.6.4
Working offline
7.6.5
Macros
7.6.6
Disadvantages
8
reveal.js Presentations
8.1
Display modes
8.2
Appearance and style
8.2.1
Smaller text
8.3
Slide transitions
8.4
Slide backgrounds
8.5
2-D presentations
8.6
Custom CSS
8.6.1
Slide IDs and classes
8.6.2
Styling text spans
8.7
reveal.js options
8.8
reveal.js plugins
8.9
Other features
9
Community Formats
9.1
Lightweight Pretty HTML Documents
9.1.1
Usage
9.1.2
Package vignettes
9.2
The rmdformats package
9.3
Shower presentations
10
Websites
10.1
Get started
10.2
The directory structure
10.3
Deployment
10.4
Other site generators
10.5
rmarkdown’s site generator
10.5.1
A simple example
10.5.2
Site authoring
10.5.2.1
RStudio
10.5.2.2
Command line
10.5.2.3
knitr caching
10.5.3
Common elements
10.5.3.1
Content
10.5.3.2
R scripts
10.5.3.3
Rmd partials
10.5.4
Site navigation
10.5.4.1
HTML navigation bar
10.5.5
HTML generation
10.5.5.1
The htmltools package
10.5.6
Site configuration
10.5.6.1
Included files
10.5.7
Publishing websites
10.5.8
Additional examples
10.5.9
Custom site generators
10.5.9.1
Site generator function
10.5.9.2
Examples
11
HTML Documentation for R Packages
11.1
Get started
11.2
Components
11.2.1
Home page
11.2.2
Function reference
11.2.3
Articles
11.2.4
News
11.2.5
Navigation bar
12
Books
12.1
Get started
12.2
Project structure
12.2.1
Index file
12.2.2
Rmd files
12.2.3
_bookdown.yml
12.2.4
_output.yml
12.3
Markdown extensions
12.3.1
Number and reference equations
12.3.2
Theorems and proofs
12.3.3
Special headers
12.3.4
Text references
12.3.5
Cross referencing
12.4
Output Formats
12.4.1
HTML
12.4.2
LaTeX/PDF
12.4.3
E-books
12.4.4
A single document
12.5
Editing
12.5.1
Build the book
12.5.2
Preview a chapter
12.5.3
Serve the book
12.5.4
RStudio addins
12.6
Publishing
12.6.1
RStudio Connect
12.6.2
Other services
12.6.3
Publishers
13
Journals
13.1
Get started
13.2
rticles templates
13.3
Using a template
13.4
LaTeX content
13.5
Linking with bookdown
13.6
Contributing templates
14
Interactive Tutorials
14.1
Get started
14.2
Tutorial types
14.3
Exercises
14.3.1
Solutions
14.3.2
Hints
14.4
Quiz questions
14.5
Videos
14.6
Shiny components
14.7
Navigation and progress tracking
IV
Other Topics
15
Parameterized reports
15.1
Declaring parameters
15.2
Using parameters
15.3
Knitting with parameters
15.3.1
The
Knit
button
15.3.2
Knit with custom parameters
15.3.3
The interactive user interface
15.4
Publishing
16
HTML Widgets
16.1
Overview
16.2
A widget example (sigma.js)
16.2.1
File layout
16.2.2
Dependencies
16.2.3
R binding
16.2.4
JavaScript binding
16.2.5
Demo
16.3
Creating your own widgets
16.3.1
Requirements
16.3.2
Scaffolding
16.3.3
Other packages
16.4
Widget sizing
16.4.1
Specifying a sizing policy
16.4.2
JavaScript resize method
16.5
Advanced topics
16.5.1
Data transformation
16.5.1.1
HTMLWidgets.dataframeToD3()
16.5.1.2
HTMLWidgets.transposeArray2D()
16.5.1.3
Custom JSON serializer
16.5.2
Passing JavaScript functions
16.5.3
Custom widget HTML
16.5.4
Create a widget without an R package
17
Document Templates
17.1
Template structure
17.2
Supporting files
17.3
Custom Pandoc templates
17.4
Sharing your templates
18
Creating New Formats
18.1
Deriving from built-in formats
18.2
Fully custom formats
18.3
Using a new format
19
Shiny Documents
19.1
Getting started
19.2
Deployment
19.2.1
ShinyApps.io
19.2.2
Shiny Server / RStudio Connect
19.3
Embedded Shiny apps
19.3.1
Inline applications
19.3.2
External applications
19.4
Shiny widgets
19.4.1
The
shinyApp()
function
19.4.2
Example: k-Means clustering
19.4.3
Widget size and layout
19.5
Multiple pages
19.6
Delayed rendering
19.7
Output arguments for render functions
19.7.1
A caveat
Back Matter
References
Index
Preface
About the Authors
This book is primarily put together by me (Yihui Xie), making use of the existing R documentation of the
rmarkdown
package and the
rmarkdown
website, which were mainly contributed by J.J. Allaire and Garrett Grolemund.
🔗
🔗