Here in markdown, comments do not require the hashtag symbol (#) to define them. Instead, the codes are written into denoted blocks or sections

Using the Toothgrowth dataset where guinea pigs were given amounts of vitaminC to see the effects on the animals tooth growth.

To open a new block use the “`” symbol 3 times and write “r” in curly brackets as shown;

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

Running the play button in the code block runs the code with the results printed within the R markdown file

fit<- lm(len ~ dose, data = Toothdata)
b<- fit$coefficients
  plot(len ~ dose, data = Toothdata)
  
abline(lm(len ~ dose, data = Toothdata))
Fig.1: The variable growth of tooths in relation to Vitamin c dosage

Fig.1: The variable growth of tooths in relation to Vitamin c dosage

The slop of the regression line is 9.7635714.

Section headers

Hashtags (#) create sections and subsections within the R markdown similar to a word document to denote texts. Remember to put spaces after the tag to enable it run

first level

This is the start of tab, go down to ‘tabs’ to learn more

second level

third level

We can create bullet points by using the hyphen (-).Indentation matters as well as ending with a fullstop

  • first item
  • second item
    • second layer
    • second item

We can also list items as shown;

  1. First
  2. Second
  3. Third
    1. section i
    2. section ii

Block Quotes

We make quotes by using the greater than sign (>). E.g;

“Everything works out for me in the end”

~Noble Alfred

Formulas

Formatted formulars can be written using two dolar signs ($) before and after the equation as shown;

Olms Law

\[ V = IR \] You can use laTex to find out more commands to create and design more complex markdown scripts

Code Chunk options

Knitr interprets the code into a HTML file and also converts it to a PDF or other options;

eval (T or F): When typed into the code block/chuck headed, determines whether or not the output is evaluated and shown before Knitr displays it in the HTML doc

echo (T or F): when typed, determines whether the code is shown when displayed in the HTML doc

fig.width & fig.height: determines the size of plots in inches on knitr before rendering them in the images when saved separately

out.width & out.height: changes the size of the plot in the HTML markdown itself when rendering

fig.cap: adds a caption to plots and images in the R script when rendered

Table of Content

Altering the YAML (code at the very top) by adding the word “toc: true”

\[title: "HTML Tutorial"\\ author: "Alfred"\\ date: "2026-09-13"\\ output: html_document:\\ toc_float: true \]

Tabs

We can add tabs on our markdown file by adding “{.tabset}” to a level one header, making all level two headers the sub-tabs

Themes & Highlight

Themes that change certain aspects of your HTML rendering can be done by adding functions to the YAML; Like this;

\[ title: "HTML Tutorial"\\ author: "Alfred"\\ date: "2026-09-13"\\ output: html_document:\\ toc_float: true\\ theme: united\\ highlights: expresso \]

Code folding

This allows the reader to choose between showing the code and hiding it. It is done by adding “code_folding: hide” in the YAML. Like this;

\[title: "HTML Tutorial"\\ author: "Alfred"\\ date: "2026-09-13"\\ output: html_document:\\ code_folding: hide \]

Summary

I couldn’t get my YAML to incorporate the extra features for some reason, but its a rather nice example of a publishable HTML markdown. I’ll work on it and be back with feedback