this is how you write comments in the rmardown without hashtag symbols.
to run the r code in markdown by denoting the section of code by calling the code “code chunks”.
Below is a code chunks:
## 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
to run the code just use “play” button and the result will be printed in the r markdown file.
fit <- lm(len ~ dose, data = toothdata)
b <- fit$coefficients
plot(len ~ dose, data = toothdata)
abline(lm(len ~ dose, data = toothdata))Figure 1: Guinea Pig tooth growth
the slope of the regression line is 9.7635714.
Section and subsection in r markdown, by using ‘#’ similar to number or bullet points
put space after the hash-tag
to add the bullet point- type in R markdown
in r markdown indentation matters!
the quotes can be added by using ‘>’
“Genes are ike the stor, and DNA is the language that the story us written in.”
— Sam Kean
Hyperlinks can be incorporated into HTML files by using the link…to r markdown’s homepage for this example. RMarkdown
to put formatted formulas into markdown using two dollar signs.
Hardy-weinberg Formula
\[p^2 + 2pq + q^2 = 1\]
and you get really complex as well!
\[ \Theta = \begin {pmatrix} \alpha & \beta \\ \gamma & \ \delta \end {pmatrix}\]
The backslash with name of Greek alphabet will give the Greek symbols example: (make sure there is no space between and the name)
there are also options for knitr which interprets code chunk. it has following options.
Eval (T or F): whether or not to evaluate the code chunk
Echo (T or F) : whether or not to show the code for the chunk but result will be printed.
Cache: if you do not want to want evaluated knitr again, enable it. specially in long runtimes.
fig.width or fig.height: graphical tool - plots in inches. write figures in the knitr then in a separate files.
out.width or out.height: the output size of the r plots in the r dcument.
fig.cap: to create figure captions.
to add the table of contents using the YAML code which can be added at the very top of the document. by adding this way: title: “HTML class” author: “Preeti” date: “2024-08-14” output: html_document: toc: true toc_float: true
this will give us a floating table of content on the right hand side of the documents.
to add tabs by specifying the each section adding “{.tabset}” after the line. every subsequent header will be a new tab.
on adding themes which will change the highlighting color and hyperlink colour by adding theme in YAML following:
cerulean journal flatly readable spacelab united cosmo lumen paper sandstone sipmplex yet null
to change the color by specifying highlight:
default tango payments kate monochrome espresso zenburn haddock textmate
the code_folding option allow us to toggle between displaying the code and hiding the code by:
there are many options to customize the HTML format. can be used to display a “portofolio” of your work.
code_folding:hide