

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
R studio markdown method with images of workflow
Typology: Cheat Sheet
1 / 2
This page cannot be seen from the preview
Don't miss anything!


input - file to render output_format output_options - List of render options (as in YAML) output_file output_dir params - list of params to use envir - environment to evaluate code chunks in encoding - of input file
CC BY RStudio
Rmd
Modify chunk options
Run all previous chunks
Run current chunk
Insert code chunk
Go to code chunk
Run code chunk(s)
Set preview location
Open in window
Save Find and replace
Use the wizard that opens to pre-populate the file with a template
Spell Check
Publish Show outline
Reload document Find in document File path to output document
Synch publish button to accounts at
Optional section of render (e.g. pandoc) options written as key:value pairs (YAML).
Narration formatted with markdown, mixed with:
Chunks of embedded code. Each chunk:
***** Your report will rendered as a Shiny app, which means you must choose an html output format, like html_document, and serve it with an active R Session.
output: html_document runtime: shiny
numericInput("n", "How many cars?", 5) renderTable({ head(cars, input$n) })Embed a complete app into your document with shiny:: shinyAppDir()
Insert with r. Results appear as text without code.
Built with r getRversion()
Set with knitr:: opts_chunk$set() , e.g.
knitr::opts_chunk$set(echo = TRUE) getRversion()One or more lines surrounded with {r}** and **. Place chunk options within curly braces, after r. Insert with
params: n: 100 d: !r Sys.Date()
Today’s date is r params$d
Indent 2 spaces
Options not listed above: R.options, aniopts, autodep, background, cache.comments, cache.lazy, cache.rebuild, cache.vars, dev, dev.args, dpi, engine.opts, engine.path, fig.asp, fig.env, fig.ext, fig.keep, fig.lp, fig.path, fig.pos, fig.process, fig.retina, fig.scap, fig.show, fig.showtext, fig.subcap, interval, out.extra, out.height, out.width, prompt, purl, ref.label, render, size, split, tidy.opts
CC BY RStudio
Plain text End a line with two spaces to start a new paragraph. italics and bold verbatim code sub/superscript^2^~2~ strikethrough escaped: * _ \ endash: --, emdash: --- equation: $A = \pi*r^{2}$ equation block:
$$E = mc^{2}$$ > block quote
\textbf{Tex ignored in HTML} HTML ignored in pdfs
link Jump to Header 1 image:
(@) A list whose numbering continues after
(@) an interruption Term 1 : Definition 1
RightLeftDefaultCenter 12121212 123123123123 1111(>- to have bullets appear on click) horizontal rule/slide break:
A footnote [1]
(^1) file (optional) in the YAML header
2
3 of document
Smith cited [@smith04]. Smith cited without author [-@smith04]. @smith04 cited in line.
bibliography: refs.bib csl: style.csl
1
2
4
3 Install the package
template.yaml
Write with syntax on the left to create effect on right (after render)
data <- faithful[1:4, ]
print(xtable:: **xtable(** data, caption = "Table with xtable" **)** , type = "html", html.table.attributes = "border=0")) stargazer:: **stargazer(** data, type = "html", title = "Table with stargazer" **)** knitr:: **kable(** data, caption = "Table with kable" **)**sub-option description
citation_package The LaTeX package to process citations, natbib, biblatex or none X X X code_folding Let readers to toggle the display of R code, "none", "hide", or "show" X colortheme Beamer color theme to use X css CSS file to use to style document X X X 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 fig_caption Should figures be rendered with captions? X X X X X X X fig_height, fig_width (^) Default figure height and width (in inches) for document X X X X X X X X X X highlight Syntax highlighting:^ "tango",^ "pygments",^ "kate","zenburn",^ "textmate"^ X X X X X includes File of content to place in document^ (in_header, before_body, after_body)^ X X X X X X X X incremental Should bullets appear one at a time (on presenter mouse clicks)? X X X keep_md Save a copy of .md file that contains knitr output X X X X X X keep_tex Save a copy of .tex file that contains knitr output X X latex_engine Engine to render latex, "pdflatex", "xelatex", or "lualatex" X X lib_dir Directory of dependency files to use (Bootstrap, MathJax, etc.) X X X mathjax Set to local or a URL to use a local/URL version of MathJax to render X X X md_extensions Markdown extensions to add to default definition or R Markdown X X X X X X X X X X number_sections Add section numbering to headers X X pandoc_args Additional arguments to pass to Pandoc X X X X X X X X X X preserve_yaml Preserve YAML front matter in final document? X reference_docx docx file whose styles should be copied when producing docx output X self_contained Embed dependencies into the doc X X X slide_level The lowest heading level that defines individual slides X smaller Use the smaller font size in the presentation? X smart Convert straight quotes to curly, dashes to em-dashes, … to ellipses, etc. X X X template Pandoc template to use when rendering file X X X X X theme Bootswatch or Beamer theme to use for page X X toc Add a table of contents at start of document X X X X X X X toc_depth The lowest level of headings to add to table of contents X X X X X X toc_float Float the table of contents to the left of the main content X
htmlpdfwordodt rtfmd ioslides
slidy beamer
Options not listed: extra_dependencies, fig_crop, fig_retina, font_adjustment, font_theme, footer, logo, html_preview, reference_odt, transition, variant, widescreen
When you render, R Markdown
Set a document’s default output format in the YAML header:
output value creates html_document html pdf_document pdf (requires Tex ) word_document Microsoft Word (.docx) odt_document OpenDocument Text rtf_document Rich Text Format md_document Markdown github_document Github compatible markdown ioslides_presentation ioslides HTML slides slidy_presentation slidy HTML slides beamer_presentation Beamer pdf slides (requires Tex)
output: html_document: code_folding: hide toc_float: TRUE
Indent 2 spaces
Indent 4 spaces
text 1
text 2
html tabsets
gituhb
Learn more in the stargazer, xtable , and knitr packages.
Here is the footnote. ↩