td1<-ToothGrowth
head(td1)
##    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=td1)
fit
## 
## Call:
## lm(formula = len ~ dose, data = td1)
## 
## Coefficients:
## (Intercept)         dose  
##       7.422        9.764
plot(len~dose,data=td1)
abline(lm(len~dose,data=td1))
Figure 1:tooth growth of pigs when various amounts of vitamin C was given

Figure 1:tooth growth of pigs when various amounts of vitamin C was given

code chunk options

Introduction

To get the slope of the regression we need to use the function abline, which gives us the center line and shows us if it’s a positive or a negative regression.
In the above example, as the regression line is rising, it means that it is a positive regression.


Headings

In R Markdown, we use # to write headings and subheadings:
- # is the first-level header
- ## is the second-level header
- ### is the third-level header


Lists

Bulleted Lists

To add bullet items, use -. For sub-bullets, press Tab and add another -:
- One item
- One item
- Sub-item
- Sub-sub-item

Numbered Lists

Numbered lists can also be created:
1. First
2. Second
3. Third
- Sub-item
- Sub-sub-item


Additional Formatting

Quotes

In R Markdown, we can use > to create quotes:
> “DNA is life”


Mathematical Formulas

Formulas can be displayed using $$ for inline LaTeX math:
\[p^2 + 2pq + q^2 = 1\]


Code Execution Options

eval (Evaluate Code) The eval option determines whether a code chunk is executed:

print("Hello, world!")

table of contents

in YAML the use of toc: function lets us arrange all the headings in the html file into table of contents and show it at the start of the page.

toc_float

this function can be used to present all the headings in a float manner instead of at the start of the html page. this is the format

title: “html” author: “rakesh” date: “2025-02-10” output: html_document: toc: true toc_float: true —

tabs

we can also add tables in our html page, this needs specification of the block of code that needs to go into the tab. “{.tabset}”this is the code for it.

themes

we can also add themes to the html page that changes the color of the text, hyperlink etc on the html page. makes it more better looking. to do this we change this in the YAML using the following:

cerulean hournal flartly readable spacelab united consmo lumen paper sandstone simplex yeti null

we can also change the color by specifying highlight. default tango payments kate monochrome espresso zenburn haddock textmate

code folding

we can use this option to display or hide the junk of code in the html page, can be done by code_folding: hide