1.Run render

## Some inter commands
#rmarkdown::render()
#rmarkdown::render('file.Rmd', 'pdf_document')

2.R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

3.Including Plots

You can also embed plots, for example:

plot(pressure)

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

4.Markdown syntax

Precisely speaking, it is Pandoc’s Markdown.

4.1 Inline formatting

1.italic if surrounded by underscores or asterisks, e.g., _text_ or *text*

2.Bold text is produced using a pair of double asterisks **text**

3.subscript e.g., H~3~PO~4~ renders H3PO4

4.carets (^) produce a superscript (e.g., Cu^2+^ renders Cu2+).

5.To mark text as inline code, use a pair of backticks, e.g., code.

6.Hyperlinks are created using the syntax [text](link), e.g., RStudio.

7.The syntax for images is similar: just add an exclamation mark, e.g., ![alt text or image title](path/to/image).

8.Footnotes are put inside the square brackets after a caret ^[], e.g., ^[This is a footnote.].

4.2 Block-level elements

# First-level header

## Second-level header

### Third-level header

If you do not want a certain heading to be numbered, you can add {-} or {.unnumbered} after the heading, e.g.,

Unordered list items start with *, -, or +, and you can nest one list within another list by indenting the sub-list, e.g.,

  • one item

  • one item

  • one item

    • one more item

    • one more item

    • one more item

Blockquotes are written after >, e.g.,

“I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him.”

— Mark Twain

4.3 Math expressions

Inline LaTeX equations can be written in a pair of dollar signs using the LaTeX syntax, e.g., $f(k) = {n \choose k} p^{k} (1-p)^{n-k}$ (actual output: \(f(k) = {n \choose k} p^{k} (1-p)^{n-k}\);

math expressions of the display style can be written in a pair of double dollar signs, e.g., $$f(k) = {n \choose k} p^{k} (1-p)^{n-k}$$, and the output looks like this:\[f(k) = {n \choose k} p^{k} (1-p)^{n-k}\]