R Markdown::: Cheat Sheet
R Markdown::: Cheat Sheet
R Markdown::: Cheat Sheet
Parameters
based slides, Notebooks, and more.
modify run
chunk current
Workflow
options chunk
Parameterize your documents to reuse with
different inputs (e.g., data, values, etc.)
---
1. Add parameters · Create and set params:
parameters in the header as sub- n: 100
values of params d: !r Sys.Date()
---
2. Call parameters · Call parameter
values in code as params$<name>
6 Today’s date
3. Set parameters · Set values wth is `r params$d`
1 Open a new .Rmd file at File ▶ New File ▶
Knit with parameters or the params
R Markdown. Use the wizard that opens to pre- argument of render():
populate the file with a template 7 render("doc.Rmd", params = list(n = 1,
2 Write document by editing template d = as.Date("2015-01-01"))
RStudio® is a trademark of RStudio, Inc. • CC BY SA RStudio • info@rstudio.com • 844-448-1212 • rstudio.com • Learn more at rmarkdown.rstudio.com • rmarkdown 1.6 • Updated: 2016-02
Pandoc’s Markdown Set render options with YAML
Write with syntax on the left to create effect on right (after render)
Plain text
When you render, R Markdown
1. runs the R code, embeds results and text into .md file with knitr
rmarkdown
End a line with two spaces
to start a new paragraph. 2. then converts the .md file into the finished format with pandoc
*italics* and **bold**
beamer
ioslides
`verbatim code`
gituhb
word
html
slidy
sub/superscript^2^~2~ sub-option description
odt
pdf
md
rtf
~~strikethrough~~
escaped: \* \_ \\ citation_package The LaTeX package to process citations, natbib, biblatex or none X X X
endash: --, emdash: ---
Set a document’s code_folding Let readers to toggle the display of R code, "none", "hide", or "show" X
equation: $A = \pi*r^{2}$
default output format ---
equation block: output: html_document colortheme Beamer color theme to use X
in the YAML header: ---
$$E = mc^{2}$$ # Body css CSS file to use to style document X X X
> block quote dev Graphics device to use for figure output (e.g. "png") X X X X X X X
duration Add a countdown timer (in minutes) to footer of slides X
# Header1 {#anchor} output value creates
fig_caption Should figures be rendered with captions? X X X X X X X
## Header 2 {#css_id} html_document html
fig_height, fig_width Default figure height and width (in inches) for document X X X X X X X X X X
### Header 3 {.css_class}
pdf_document pdf (requires Tex )
word_document Microsoft Word (.docx) highlight Syntax highlighting: "tango", "pygments", "kate","zenburn", "textmate" X X X X X
#### Header 4 includes File of content to place in document (in_header, before_body, after_body) X X X X X X X X
odt_document OpenDocument Text
##### Header 5 rtf_document Rich Text Format incremental Should bullets appear one at a time (on presenter mouse clicks)? X X X
###### Header 6 md_document Markdown keep_md Save a copy of .md file that contains knitr output X X X X X X
<!--Text comment--> github_document Github compatible markdown keep_tex Save a copy of .tex file that contains knitr output X X
ioslides_presentation ioslides HTML slides latex_engine Engine to render latex, "pdflatex", "xelatex", or "lualatex" X X
\textbf{Tex ignored in HTML}
<em>HTML ignored in pdfs</em> slidy_presentation slidy HTML slides lib_dir Directory of dependency files to use (Bootstrap, MathJax, etc.) X X X
<http://www.rstudio.com> beamer_presentation Beamer pdf slides (requires Tex) mathjax Set to local or a URL to use a local/URL version of MathJax to render equations X X X
[link](www.rstudio.com)
Jump to [Header 1](#anchor) Indent 2 Indent 4 md_extensions Markdown extensions to add to default definition or R Markdown X X X X X X X X X X
image: Customize output with spaces spaces number_sections Add section numbering to headers X X
---
sub-options (listed to output: html_document:
![Caption](smallorb.png) the right): code_folding: hide pandoc_args Additional arguments to pass to Pandoc X X X X X X X X X X
* unordered list toc_float: TRUE preserve_yaml Preserve YAML front matter in final document? X
+ sub-item 1 ---
+ sub-item 2 # Body reference_docx docx file whose styles should be copied when producing docx output X
- sub-sub-item 1 self_contained Embed dependencies into the doc X X X
* item 2 html tabsets slide_level The lowest heading level that defines individual slides X
Continued (indent 4 spaces)
Use tablet css class to place sub-headers into tabs smaller Use the smaller font size in the presentation? X
1. ordered list # Tabset {.tabset .tabset-fade .tabset-pills} smart Convert straight quotes to curly, dashes to em-dashes, … to ellipses, etc. X X X
2. item 2 ## Tab 1 template Pandoc template to use when rendering file quarterly_report.html). X X X X X
i) sub-item 1
A. sub-sub-item 1 text 1 Tabset theme Bootswatch or Beamer theme to use for page X X
(@) A list whose numbering ## Tab 2 Tab 1 Tab 2 toc Add a table of contents at start of document X X X X X X X
text 2 toc_depth The lowest level of headings to add to table of contents X X X X X X
continues after text 1
### End tabset End tabset toc_float Float the table of contents to the left of the main content X
(@) an interruption
Term 1
: Definition 1