title: “HTML” author: “Chance” date: “2024-11-05” output: html_document: toc: true toc_float: True Theme: spacelab code_folding: hide —
reproducable reasurch
Here we can type long passages or discriptions of our data without using the #symbol in our first example we will be using the toothgrow dataset. in this experiment guinea pigs were given different amount of vitemen c to see tooth growth
to run r code in markdown in markdown fikle we need to denote the section that is condodered r code we call these sections chunks
below is a 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 you can see from running the play button on the code chunk the results are printed inline of the rmarkdown file
fit <- lm(len ~ dose ,data = toothdata)
b <- fit$coefficients
plot(len ~ dose, data = toothdata)
abline(lm(len ~ dose, data = toothdata))
Figure 1: The tooth growth of Guinea pigs when given variable amounts of Vitamin C
The slope of the regression line is 9.7635714
we can put sections and sub sections in our r markdown file similar to numbers or bullet points in a word document this is done with # that we used to denote text in r script
make sure you put a space after the # otherwise it will not work
you can also you bullet point type marks in r markdown file - one item - one item - one item - one more item - one more item - one more item
it is important to note here that our markdown indentation matters
we can put nice quotes into markdown document. we do this by using the > symbol > Genes are like the story and DNA is like the language that the story is written in. > > >— Sam Keen
hyperlinks can also be incorperated 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 youb are interested in showing them. here we will use the link to rmark downs home page for this example
we can also put nuce formated formulas into markdown using two doller signs
\[p^2 + 2pq + q^2 = 1\]
an dyou can get really complex
\[\theta = \begin{pmatrix\alpha} & beta\\ \gama & \delta \end(pmatrix}\]
print("Hello world")
there are also options for r markdown file on how kniter interpurets the code chunk. there are the following options
eval (t or f ) wethir or not it evaluates the code chunk
echo (t or f) wether or not to show the code for the chunk but result will stay the same
cashe: if enable the same code chunk will not be evaluated the next time that the kinter is run great for code that has long run times
fig.width or fig.heiggt the (graphical device) size of the r plots in inches the figures are first written to the knitter document then to files that are saved seperate out.width or out.height- the output size of the rplots in the document.
fig.cap- the words for the figure captions
we can also add a table of contents to our HTML document by altering the YAML the weird code chunk at the top
You can also add tabs in our report to do this you have to specify each section you want to be come a tab using this code “{.tabset}” after the line
You can also add theme to your HTML document that change the highting color and hyperlink color of your HTML can be nice astheticlly to do this you change your theme in the YAML to one of the following
cerulean journal flatly cosmo lumen paper simplex yeti null sandstone
you can use code folding for the reader to toggle between displaying the code and hiding the code this is done with:
code_folding: hide
These are a ton of ways to customize you r code with the HTML format this is also a great way to market yourself to interested parties.