R markdown is a tool which consize your data in to one particular format whhich makes it easy for the researchers that are working in different coiuntries to share their priogress/ code and etc. Today we will be learning about R markdown HTML demo We need to define a segment of code before writing it and those chunks are known as “code chunks”
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$coeffcients
plot (len ~ dose, data= Toothdata)
abline(lm(len~dose, data =Toothdata))
The slope of the regression line is ’ r b[2]’
We can also put section and subsections in our R markdown file similar to number or bullets in a word documents. Thi sis don eby “#” that we previously used for denoting text in a R script
after # you need to include space otherwise this is not considered by R markdown
We can alsoinclude/ add bullet points just like the word document
” Genes are like the story and DNA is the language ini which it is written”
— Sid singh
Hyperlinks can also be included into these files, this is specifically useful in HTML files since they are in a web browser and will redirect the reader to the material that you are intersted in showing them is the symbol that is used for inserting hyperlinks []
are used to put formulas such as this Hardy-Weinberg equation \[p^2 +2pq + q^2 = 1\]
These are the oprions for your R markdown file on how knitr interprets the code chunks Eval (T or F): whether or not to evaluate the 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
Echo (T or F): whether or not to show the code chunk, but the results will be printed
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
cache: if enable the same code chunk will not be evaluated the next time that the knitr is run. Great for code that have long RUNNING time.
fig.width or fig.height: the (graphical device) size of the R plots in inchs. the figures are the first written to knit document then to files that are saved separately
out.width or out.height: the output size of the R plots in R doc
Fig.cap: Figure 1: “guinea pig toothdata set”
fit <-lm(len~dose, data =Toothdata)
b <- fit$coeffcients
plot (len ~ dose, data= Toothdata)
abline(lm(len~dose, data =Toothdata))
Figure 1: guinea pig toothdata set
We can add the table of content by altering the YAML code (the weired code that is written at the top most region of your r markdown file)
We can also add tabs in our output report. we just have use {.tabset} after the line to which we want to make it a tab. This will create different tabs for subheading that are included in the main heading