Professional Documents
Culture Documents
RMarkdownCheatSheet PDF
RMarkdownCheatSheet PDF
Use it to
.Rmd !
A plot:
```{r}
!
A plot:
```{r}
!
A plot:
```{r} =
A plot:
=
Microsoft
Word
2. Open File Start by saving a text file with the extension .Rmd, or open 3. Markdown Next, write your report in plain text. Use markdown syntax to
an RStudio Rmd template describe how to format text in the final report.
syntax becomes
In the menu bar, click Plain text
File New File R Markdown End a line with two spaces to start a new paragraph.
*italics* and _italics_
A window will open. Select the class of output **bold** and __bold__
you would like to make with your .Rmd file superscript^2^
~~strikethrough~~
Select the specific type of output to make [link](www.rstudio.com)
with the radio buttons (you can change this !
# Header 1
later) !
## Header 2
Click OK !
### Header 3
!
#### Header 4
!
##### Header 5
!
###### Header 6
4. Choose Output Write a YAML header that explains what type of !
endash: --
document to build from your R Markdown file. emdash: ---
ellipsis: ...
inline equation: $A = \pi*r^{2}$
---
YAML title: "Untitled" image: ![](path/to/smallorb.png)
author: "Anonymous" The RStudio
A YAML header is a set of key: output: html_document
template writes horizontal rule (or slide break):
value pairs at the start of your !
---
the YAML header
!
file. Begin and end the header ***
with a line of three dashes (- - -)
This is the start of my
report. The above is metadata
saved in a YAML header.
for you !
> block quote
!
* unordered list
The output value determines which type of file R will build from your .Rmd file (in Step 6)
* item 2
output: html_document html file (web page) + sub-item 1
+ sub-item 2
output: pdf_document pdf document 1. ordered list
2. item 2
output: word_document Microsoft Word .docx + sub-item 1
+ sub-item 2
output: beamer_presentation beamer slideshow (pdf) !
Table Header | Second Header
output: ioslides_presentation ioslides slideshow (html) ------------- | -------------
Table Cell | Cell 2
Cell 3 | Cell 4
RStudio is a trademark of RStudio, Inc. All rights reserved info@rstudio.com 844-448-1212 rstudio.com
5. Embed Code Use knitr syntax to embed R code into your report. R 6. Render Use your .Rmd file as a blueprint to build a finished report.
will run the code and include the results when you render your report.
inline code code chunks Render your report in one of two ways
Surround code with back ticks and r. Start a chunk with ```{r}.
1. Run rmarkdown::render("<file path>")
R replaces inline code with its results. End a chunk with ```
2. Click the knit HTML button at the top of
Two plus two Heres some code the RStudio scripts pane
equals `r 2 + 2`. ```{r}
dim(iris)
```
When you render, R will
execute each embedded code chunk and insert the results into your report
build a new version of your report in the output file type
display options open a preview of the output file in the viewer pane
Use knitr options to style the output of a chunk.
save the output file in your working directory
Place options in brackets above the chunk.
8. Publish Share your report where users can visit it online 9. Learn More
Documentation and examples - rmarkdown.rstudio.com
Rpubs.com ShinyApps.io Click the "Publish" button in the RStudio
Further Articles - shiny.rstudio.com/articles
preview window to publish to rpubs.com
Share non-interactive Host an interactive document zzzz
with one click. ! - blog.rstudio.com
documents on RStudios free R on RStudios server. Free and " - @rstudio
Markdown publishing site paid options
RStudio and Shiny are trademarks of RStudio, Inc.
www.rpubs.com www.shinyapps.io All rights reserved info@rstudio.com
844-448-1212 rstudio.com