1. Headings

Headings are proceed by #. The number of # at the beginning of a line indicates the level of heading (main section, sub section, sub-sub section, etc.)

Here is an illustration.

H1 level

This is header level 1

H2 level

This is header level 2

H3 level

This is header level 3 and so on.

2. Text Formatting

This text is in italics. And so is this text.

This text is in bold. And so is this text.

This text is rendered with strikethrough.

3. Bullet Points

or

or

4. Numbered List

  1. Item one
  2. Item two
  3. Item three

5. Code Chunks

Example 1

set.seed(20205)
x <- rnorm(10)
summary(x)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -2.1341 -1.1879  0.4502 -0.1464  0.7082  1.0402

Example 2: Remove hashtag in the output

set.seed(20205)
x <- rnorm(10)
summary(x)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-2.1341 -1.1879  0.4502 -0.1464  0.7082  1.0402 

Example 3: Display only the output

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-2.1341 -1.1879  0.4502 -0.1464  0.7082  1.0402 

Example 4: Display only the code

set.seed(20205)
x <- rnorm(10)
summary(x)

Example 5: Code chunk with figures

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.6     ✓ dplyr   1.0.7
## ✓ tidyr   1.1.4     ✓ stringr 1.4.0
## ✓ readr   2.0.2     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
qplot(data=iris, x=Sepal.Length, y=Sepal.Width, geom="point")

Example 6: Hide warnings and messages

library(tidyverse)
qplot(data=iris, x=Sepal.Length, y=Sepal.Width, geom="point")

Example 7: Include a figure caption

qplot(data=iris, x=Sepal.Length, y=Sepal.Width, geom="point")
Scatterplot of Sepal Width vs Sepal Length

Scatterplot of Sepal Width vs Sepal Length

Example 8: Control figure size

qplot(data=iris, x=Sepal.Length, y=Sepal.Width, geom="point")
Scatterplot of Sepal Width vs Sepal Length

Scatterplot of Sepal Width vs Sepal Length

6. Mathematical Formulae

The general formula for the probability density function of the normal distribution with mean \(\mu\) and variance \(\sigma\) is given by

\[ f_X(x) = \frac{1}{\sigma\sqrt{(2\pi)}} e^{-(x-\mu)^2/2\sigma^2}. \]

More examples

Example 1: Fraction ()

\[\frac{a}{b}=\frac{c}{b}\]

Example 2: Bold math symbols

\[\mathbf{(X'X)^{-1}X'Y}\]

Example 3: Summation, Superscript (^) and Subscript (_)

\[\sum_{i=1}^{n}{x_i^2}\]

Example 4: Equation with multiple lines

Example 4.1:

\[ \begin{eqnarray} P(|X-\mu| > k) & = & P(|X-\mu|^2 > k^2)\\ & \leq & \frac{\mathbb{E}\left[|X-\mu|^2\right]}{k^2}\\ & \leq & \frac{\mathrm{Var}[X]}{k^2} \end{eqnarray} \]

Example 4.2:

\[ \begin{eqnarray} X & \sim & \mathrm{N}(0,1)\\ Y & \sim & \chi^2_{n-p}\\ R & \equiv & X/Y \sim t_{n-p} \end{eqnarray} \]

Example 5: Parenthesis ((…))

\[\left(\sum_{i=1}^{n}{i}\right)^2\]

7. Tables

Method 1

library(knitr)
kable(iris[1:5,], caption="A knitr kable 1")
A knitr kable 1
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
5.1 3.5 1.4 0.2 setosa
4.9 3.0 1.4 0.2 setosa
4.7 3.2 1.3 0.2 setosa
4.6 3.1 1.5 0.2 setosa
5.0 3.6 1.4 0.2 setosa
kable(summary(iris), caption="A knitr kable 2")
A knitr kable 2
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
Min. :4.300 Min. :2.000 Min. :1.000 Min. :0.100 setosa :50
1st Qu.:5.100 1st Qu.:2.800 1st Qu.:1.600 1st Qu.:0.300 versicolor:50
Median :5.800 Median :3.000 Median :4.350 Median :1.300 virginica :50
Mean :5.843 Mean :3.057 Mean :3.758 Mean :1.199 NA
3rd Qu.:6.400 3rd Qu.:3.300 3rd Qu.:5.100 3rd Qu.:1.800 NA
Max. :7.900 Max. :4.400 Max. :6.900 Max. :2.500 NA

Method 2

Colons can be used to align columns.

Column 1 Column 2 Column 3
Tim Positive USA
Jane Negative UK
Cathy Negative AUS

There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don’t need to make the raw Markdown line up prettily. You can also use inline Markdown.

Index No Assignment 1 Assignment 2
ASXXX apply Factors
1 2 3

8. Include an External Image