I found content and format of the post Boost your productivity using Markdown exremely useful. By listing Markdown features in simplified linear fashion it demonstrates how to use them to enhance resulting documents. Because R Notebook includes R Markdown which in turn runs Pandoc’s version of Markdown language I decided to adopt this post for R Notebook users. Let’s start.

What are R Markdown and R Notebook?

R Markdown provides an authoring framework for data science. You can use a single R Markdown file to both

  • save and execute code
  • generate high quality reports that can be shared with an audience.

R Markdown documents are fully reproducible and support dozens of static and dynamic output formats.

From RStudio R Markdown Intro

An R Notebook is an R Markdown document with chunks that can be executed independently and interactively, with output visible immediately beneath the input. R Notebooks are a method of literate programming that allows for direct interaction with R while producing a reproducible document with publication-quality output.

From RStudio R Notebook Overview

Basic Markdown formatting

R Markdown supports most of basic formatting and follows Pandoc syntax.

1. Heading

 # h1 
 ## h2 
 ### h3 
 #### h4
 ##### h5
 ###### h6
 standard 

h1

h2

h3

h4

h5
h6

standard

2. Emphasis

*Italic type*
**Bold**
~~Strikeout~~
H~2~O is subscript
2^10^ is 1025 and superscript

Italic type
Bold
Negative H2O is subscript 210 is 1025 and superscript

3. Fold

Fold the long sentences. Again, works asis with R Notebook.

<details>
  <summary>An R Notebook is an R Markdown document with chunks that can be executed 
  independently and interactively, with output visible immediately beneath the input.
  </summary>
  
  R Notebooks are a method of literate programming that allows for direct interaction with R while 
  producing a reproducible document with publication-quality output.

  Any R Markdown document can be used as a notebook, and all R Notebooks can be rendered to other 
  R Markdown document types. A notebook can therefore be thought of as a special execution mode 
  for R Markdown documents. 

  The immediacy of notebook mode makes it a good choice while authoring the R Markdown document and 
  iterating on code; when you are ready to publish the document, you can share the notebook directly, 
  or render it to a publication format with the Knit command.
</details>

An R Notebook is an R Markdown document with chunks that can be executed independently and interactively, with output visible immediately beneath the input. R Notebooks are a method of literate programming that allows for direct interaction with R while producing a reproducible document with publication-quality output.

Any R Markdown document can be used as a notebook, and all R Notebooks can be rendered to other R Markdown document types. A notebook can therefore be thought of as a special execution mode for R Markdown documents.

The immediacy of notebook mode makes it a good choice while authoring the R Markdown document and iterating on code; when you are ready to publish the document, you can share the notebook directly, or render it to a publication format with the Knit command.

4. List

- List 1
- List 2
* List 3
* List 4
  • List 1
  • List 2
  • List 3
  • List 4

6. Check box

Markdown syntax for check box doesn’t seem to be part of R Markdown. But with support for raw HTML Markdown allows to insert tags anywhere in a document.

<input type="checkbox" checked> Task 1</input>
<input type="checkbox"> Task2</input> 

Task 1
Task2

7. Quotation


> Quotation
> Quotation Quotation

Quotation
Quotation Quotation

8. Horizontal line

***




9. Image

![Image title](https://h2o2016.wpengine.com/wp-content/themes/h2o2016/images/H2O_logo_2017.svg)
Image title

Image title

10. Source Code

The whole premise of R Notebook lies on the concept of interweaving Markdown language and R code. R Notebook integration is seamless, interactive and independent and uses the concept of R code chunks (see RStudio R Notebooks for more details).

Instead of diving into extensive topic of R code chunks we show how to include arbitrary language fragment in R Notebook. They also can get executed and results embedded into notebook but discussion of knitr package language engines extending R Notebook execution environment to other languages such as Python, bash, etc. is beyond the scope.


```python
x = 'hello, python world!'
print(x.split(' '))
```
x = 'hello, python world!'
print(x.split(' '))

11. Table

No big surprise that R Markdown supports table syntax natively.

|Fruits|Price|
|:--|:--|
|Apple|1$|
|Grapes|4$|
|Orange|2$|
|Lemon|1$|
|Peach|3$|
|Melon|20$|
Fruits Price
Apple 1$
Grapes 4$
Orange 2$
Lemon 1$
Peach 3$
Melon 20$

12. Footnote

Here is a footnote reference,[^1] and another.[^longnote]

[^1]: Here is the footnote.

[^longnote]: Here's one with multiple blocks.

Here is a footnote reference,1 and another.2

Complex formatting with R Notebook

1. Mathematical formatting (Latex)

R Notebook supports LaTex math.

Inline formulas

A linear regression line has an equation of the form $Y = a + bX$, where $X$ is the explanatory variable and $Y$ is the dependent variable. The slope of the line is $b$, and $a$ is the intercept (the value of $y$ when $x = 0$). 

A linear regression line has an equation of the form \(Y = a + bX\), where \(X\) is the explanatory variable and \(Y\) is the dependent variable. The slope of the line is \(b\), and \(a\) is the intercept (the value of \(y\) when \(x = 0\)).

source: Statistics 101-103, Introduction to Statistics, Yale

Displayed formulas

The logistic function $\theta$
$$\theta(s) = \frac{e^s}{1 + e^s}$$
$$s = \sum_{i=0}^d w_i * x_i$$

The logistic function \(\theta\)

\[\theta(s) = \frac{e^s}{1 + e^s}\]

\[s = \sum_{i=0}^d w_i * x_i\]

source: Caltech Machine Learning Video Library - Logistic Regression

2. Flowchart

With DiagrammeR package R Notebook supports wide variety of diagrams.

```{r, echo=FALSE}
library(DiagrammeR)
mermaid("
graph LR;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
")
```

3. Sequence

```{r, echo=FALSE}
mermaid("
sequenceDiagram
    participant Alice
    participant Bob
    Alice->John: Hello John, how are you?
    loop Healthcheck
        John->John: Fight against hypochondria
    end
    Note right of John: Rational thoughts 
prevail... John-->Alice: Great! John->Bob: How about you? Bob-->John: Jolly good! ") ```

4. Gantt diagram

```{r, echo=FALSE}
mermaid("
gantt
        dateFormat  YYYY-MM-DD
        title Adding GANTT diagram functionality to mermaid
        section A section
        Completed task            :done,    des1, 2014-01-06,2014-01-08
        Active task               :active,  des2, 2014-01-09, 3d
        Future task               :         des3, after des2, 5d
        Future task2               :         des4, after des3, 5d
        section Critical tasks
        Completed task in the critical line :crit, done, 2014-01-06,24h
        Implement parser and jison          :crit, done, after des1, 2d
        Create tests for parser             :crit, active, 3d
        Future task in critical line        :crit, 5d
        Create tests for renderer           :2d
        Add to mermaid                      :1d
")
```

5. Graphs

```{r, echo=FALSE}
grViz("
digraph boxes_and_circles {

  # a 'graph' statement
  graph [overlap = true, fontsize = 10]

  # several 'node' statements
  node [shape = box,
        fontname = Helvetica]
  A; B; C; D; E; F

  node [shape = circle,
        fixedsize = true,
        width = 0.9] // sets as circles
  1; 2; 3; 4; 5; 6; 7; 8

  # several 'edge' statements
  A->1 B->2 B->3 B->4 C->A
  1->D E->A 2->4 1->5 1->F
  E->6 4->6 5->7 6->7 3->8
}
")
```

That’s plenty. Enjoy R Notebook!

References


  1. Here is the footnote.

  2. Here’s one with multiple blocks.