

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
What is rmarkdown? using R studio. This allow person to reference the information, that could be hard core reading, to find the code.
Typology: Cheat Sheet
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Output data frames as tables using kable( data, caption ).
data <- faithful[1:4, ] knitr::kable(data, caption = "Table with kable")Other table packages include flextable , gt , and kableExtra. Set options for the entire document in the first chunk.
knitr::opts_chunk$set(message = FALSE)Surround code chunks with {r}** and ** or use the Insert Code Chunk button. Add a chunk label and/or chunk options inside the curly braces after r.
summary(mtcars)Create citations from a bibliography file, a Zotero library, or from DOI references.
Rmd
modify chunk options run all previous chunks run current chunk insert code chunk go to code chunk run code chunk(s) show outline set preview location
Insert r into text sections. Code is evaluated at render and results appear as text. "Built with r getRversion()" --> "Built with 4.1.0"
.Rmd files · Develop your code and ideas side-by-side in a single document. Run code as individual chunks or as an entire document. Dynamic Documents · Knit together plots, tables, and results with narrative text. Render to a variety of formats like HTML, PDF, MS Word, or MS Powerpoint. Reproducible Research · Upload, link to, or attach your report to share. Anyone can read or run your code to reproduce your work. insert citations add/edit attributes
The syntax on the left renders as the output on the right. OPTION DEFAULT EFFECTS echo TRUE display code in output document error FALSE TRUE (display error messages in doc) FALSE (stop render when error occurs) eval TRUE run code in chunk include TRUE include chunk in doc after running message TRUE display code messages in document warning TRUE display code warnings in document results "markup" "asis" (passthrough results) "hide" (don't display results) "hold" (put all results below all code) fig.align "default" "left", "right", or "center" fig.alt NULL alt text for a figure fig.cap NULL figure caption as a character string fig.path "figure/" prefix for generating figure file paths fig.width & fig.height^7 plot dimensions in inches out.width rescales output width, e.g. "75%", "300px" collapse FALSE collapse all sources & output into a single block comment "##" prefix for each line of results child NULL files(s) to knit and then include purl TRUE include or exclude a code chunk when extracting source code with knitr::purl() See more options and defaults by running str(knitr::opts_chunk$get())
Plain text. End a line with two spaces to start a new paragraph. Also end with a backslash to make a new line. italics and bold superscript^2^/subscript~2~ strikethrough escaped: * _ \ endash: --, emdash: ---
...
[This is a link.](link url) [This is another link][id]. At the end of the document: [id]: link url or ![Caption][id2] At the end of the document: [id2]: image.png verbatim code
multiple lines of verbatim code> block quotes equation: $e^{i \pi} + 1 = 0$ equation block: $$E = mc^{2}$$ horizontal rule:
RightLeftDefaultCenter 12121212 123123123123 1111 **HTML Tabsets** # Results {.tabset} ## Plots text text ## Tables more textstyle options
Plain text. End a line with two spaces to start a new paragraph. Also end with a backslash to make a new line. italics and bold superscript^2 /subscript 2 strikethrough escaped: * _ endash: –, emdash: — Header 1 Header 2 ... Header 6
Plots Tables text eiπ^ + 1 = 0 E = m c^2 Right Left Default Center 12 12 12 12 123 123 123 123 1 1 1 1
html_document .html pdf_document* .pdf word_document Microsoft Word (.docx) powerpoint_presentation Microsoft Powerpoint (.pptx) odt_document OpenDocument Text rtf_document Rich Text Format md_document Markdown github_document Markdown for Github ioslides_presentation ioslides HTML slides slidy_presentation Slidy HTML slides beamer_presentation* Beamer slides ***** Requires LaTeX, use tinytex::install_tinytex() Also see flexdashboard , bookdown , distill , and blogdown. Set Output Formats and their Options in YAML More Header Options
anchor_sections Show section anchors on mouse hover (TRUE or FALSE) X citation_package The LaTeX package to process citations ("default", "natbib", "biblatex") X code_download Give readers an option to download the .Rmd source code (TRUE or FALSE) X code_folding Let readers to toggle the display of R code ("none", "hide", or "show") X css CSS or SCSS file to use to style document (e.g. "style.css") X dev Graphics device to use for figure output (e.g. "png", "pdf") X X df_print Method for printing data frames ("default", "kable", "tibble", "paged") X X X X fig_caption Should figures be rendered with captions (TRUE or FALSE) X X X X highlight Syntax highlighting ("tango", "pygments", "kate", "zenburn", "textmate") X X X includes File of content to place in doc ("in_header", "before_body", "after_body") X X keep_md Keep the Markdown .md file generated by knitting (TRUE or FALSE) X X X X keep_tex Keep the intermediate TEX file used to convert to PDF (TRUE or FALSE) X latex_engine LaTeX engine for producing PDF output ("pdflatex", "xelatex", or "lualatex") X reference_docx/_doc docx/pptx file containing styles to copy in the output (e.g. "file.docx", "file.pptx") X X theme Theme options (see Bootswatch and Custom Themes below) X toc Add a table of contents at start of document (TRUE or FALSE) X X X X toc_depth The lowest level of headings to add to table of contents (e.g. 2, 3) X X X X toc_float Float the table of contents to the left of the main document content (TRUE or FALSE) X Use ? to see all of a format's options, e.g. ?html_document HTML PDF MS Word MS PPT RStudio® is a trademark of RStudio, PBC • CC BY SA RStudio • [email protected] • 844-448-1212 • rstudio.com • Learn more at rmarkdown.rstudio.com • rmarkdown 2.9.4 • Updated: 2021-
output: html_document runtime: shiny
numericInput("n", "How many cars?", 5) renderTable({ head(cars, input$n) })Render Share
title: "Document Title" author: "Author Name" output: html_document: theme: bootswatch: solar
title: "My Document" author: "Author Name" output: html_document: css: "style.css"
title: "My Document" author: "Author Name" output: html_document: toc: TRUE
params: state: "hawaii"
data <- df[, params$state] summary(data)output: html_document: theme: bg: "#121212" fg: "#E4E4E4" base_font: google: "Prompt"
This is a div with some text in it.
.Rmd .md HTML PDF DOC knitr pandoc