That is the YAML^^^

This is a tutorial on how to use markdown for reproducible reasearch here we can type longe passages or description of our data without the need of “Hashing” our comments with the # symbol. in our first example we will be using the toothGrowth dataset in this expeirent guinea pigs (literal) were given different amount of vitamin c to see the effects on the animals tooth growth

to run R code in a markdown file, we need to dentote the section that is considederd R code we call these “cod chunks”

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

As u can see from running the code chunk results are printed inline of the r Markdown file

fit <- lm(len~dose, data = Toothdata)
b <- fit$coefficients
plot(len~dose, data=Toothdata)
abline(lm(len~dose, data=Toothdata))
Figure1:Guinea pig Tooth Growth

Figure1:Guinea pig Tooth Growth

the slope of the regression is 9.7635714

section Headers

we can also add section and subsection in the markdown files, similar to the bullets point in word document with the help of hash tag

first level header

second level header

third level of header

make sure to put space for the hash tag to work

we can also add bullet point-type in the markdown file

  • one item
  • one item
  • one item
    • one item
    • one item
    • one item in markdown files indentation matters
  1. first item
  2. second item
  3. third item
    1. sub item one
    2. sub item two
    3. sub item three writing quotes

“Genes are like story, and dna are how the story is writen”

—unknown

the code chuncks

code chunck options

there are also option for your R Markdown file on how kniter interprets the code chunk. there are the following options eval (T or F): wether or not to evaluate the code chunk

if eval = to F it does not display the result of the part added to it echo attribute if set on F it does not show the part of the code added to it

Cache: if enabled the same code will not be executed next time that knitr is run great for code the has long run time

fig.width or fig.height: the (graphical device) size of the R plots in inches. The figures are first written to knitr document then to files that are saved separately. (publication perpuses)

out.width out.height: the output size of the R plots in the R Document

fig.cap: The words for the figure caption

Table of content

we can add table of content to the HTML file by altering the YAML code (The weird code chunk at the very top of the document)

title: “HTMl_Tutorial” author: “Saif” date: “2023-12-23” output: html_document: this line enables table of content toc: true this line enables the floatint toc toc_float: true

adding tabs

we can add tabs in our report. to do this you need to specify each section that you want to to become a tab by placing “{.tabset}” after teh line. Every subsequent header will be a new tab (first level header)

Themes

we can add themes that change the highlighting of the HMTL items done by changing the theme in the YAML code

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

highlights

you can also change the color by specifiying highlight

  • default
  • tango
  • payments
  • kate
  • monochrome
  • expresso
  • zenburn
  • haddock
  • textmate

code folding

you can also use code folding option in order to make the reader to toggle between displaying the code and hiding it

code_folding: hide