There we go. This is a proper Markdown document. Here I can type what I want. TO begin to code, we need to denote the secttion that R consders code.

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 you can see from running the “play” button on the code chunk. The results are printed inline the r markdown file.

fit <- lm(len ~ dose, data = Toothdata)

b <- fit$coefficients

plot(len ~ dose, data = Toothdata, 
     main = "Tooth Guineapig Analysis",
     ylab = "Length of tooth",
     xlab= "Drug dose")

abline(lm(len ~ dose, data = Toothdata))
**Figure 1.** The tooth growth of Guniea Pigs

Figure 1. The tooth growth of Guniea Pigs

The slope regression is 9.7635714

The y intercept is 7.4225

Section Headers

We can put sections in subsection in pour R markdown file similar to numbers or bullet óints ina word document. This is done with the # symbol that we previously used to denot thext in our R script.

Frist Level

Second Level Header

Third Level Header

Make sure that you put space after #, otherwise it will not work.

We can also add bullet point-type marks in our markdown file.

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

Its important to note here that in R Markdown indentation matters.

  1. First item
  2. Second item
  3. Third item
  1. sub item 1
  2. sub item 2
  3. sub item 3

Block Quotes

We can out quotes in Markdown document. Using “>” symbol.

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

— Sam Kean

Formulas

We can put formulas using two dolar signs $

\[p^2 + 2pq + q^1 = 1\] You can get more complex

\[\Theta = \begin{pmatrix}\alpha & \beta & \alpha\\ \gamma & \delta & \alpha \end{pmatrix}\]

Code Chunks

Code chunk options

cat("Hello World")
## Hello World

Options on how knit (the one that compiles and interprets code)

Eval (T or F): whether or not to evaluate code output. code will still show Echo (T or F): whether or not you show the code. output will still show

Cache: If enable, same code will not be evaluated next time that knitter is run. Great for code with LONG run times.

fig.width or fig.height: the (graphical device) size of the R plots in inches. The figures are are first written into the knitter then to files that are separately. Good for publication purposes.

out.width or out.height: The ouput size of the R plots in the R DOCUMENT.

fig.cap: the words for the figure caption.

Table of contents

Add table of contents to our HTML Documents. alter YAML code (At the top of document —YAML—). EXAMPLE : title: “HTML” author: “Francisco Romo” date: “2023-12-12” output: html_document: toc: true toc_float: true

This gives us a nice floating table of contents in the document toc = table of documents.

Tabs

You can also add tabs in our report. To do this you need to specify “{.tabset}” after the line.

Themes

You can also add themes to your HTML output. This can be nice aesthetically. To do this you change your theme in the YAML to one of the following:

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

Change color by specifying highlight:

default tango payments kate monochrome espresso zenburn haddock textmate

Code Folding

Allow reader to taggle between diplsaying the code and hiding the code. This is done with code_folding: hide

Summary

Thats the end