Below is a code chunk:

Toothdata <- ToothGrowth

head(Toothdata)
##    len supp dose
## 1  4.2   VC  0.5
## 2 11.5   VC  0.5
## 3  7.3   VC  0.5
## 4  5.8   VC  0.5
## 5  6.4   VC  0.5
## 6 10.0   VC  0.5
fit <- lm(len~dose, data = Toothdata)

b <- fit$coefficients
plot(len~dose, data = Toothdata)
abline(lm(len~dose, data = Toothdata))
Fig: 1. Guiena Pig Tooth Grwoth

Fig: 1. Guiena Pig Tooth Grwoth

The value of the slope is 9.7635714.

Section headers

First level header

Second level header

Third level header

  • one item
  • one item
  • one item
    • one more item
    • one more item
      • one last item

It’s important to note that in R markdown, indentation matters!

  1. first item
  2. second item
  3. third item
  1. subitem 1
  2. subitem 2
  3. subitem 3

Block Quotes

by putting “>”

“Genes are like the story, DNA is the language that the story was written in.”

—Sam

Formulas

We can add formula into markdown using two dollar signs.

\[ p^2+2pq+q^2=1\]

you can get really complex as well!!

\[ \theta = \begin{pmatrix}\alpha & \beta & \zeta\\ \gamma & \epsilon^2 & \mu\\ \end{pmatrix}\]

Code chunks

Code chunk options

## [1] "Hello World"

Eval (T or F): whether or not to evaluate the code chunk Echo (T or F): whether or not the show actual chunk, but the result will still print

Table of contents

by altering the YAML code at the very top of the document. we can add this:

title: “HTML_Tutorial” author: “Dr. Myat” date: “2024-05-31” output: html_document: toc: True toc_float: True

This will give us the very nice floating table of content on the right handside of the doucment.

Tabs

add tabs in our report. we need to specify each section that you want to become a tab by placing “{.tabset}” after the line. Every subsequent header will be a new tab.

Themes

You can also add themes to your HTML documents that change the highlighting colour and hyperlink colour of your HTML output. This can be nice esthetically. To do this, you change your theme in the YAML to one of the following:

cerulean journal flatly readable spacelab united cosmo lumen paper sandstone simplex yeti null

You can also change the colour by specifying highlight:

default tango payments kate monochrome espresso zenburn haddock textmate

Code folding

to allow the reader to toggle between displaying the code and hiding the code. This is done with:

code_folding: hide

Summary