This above portion between the “—” is metadata. The text other than metadata and r chuks is R markdown.

This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.

Shortcuts: 1) Shift + 8 - italicize selected text 2) Do the above twice to make text bold

Try executing the chuck by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Enter

plot(rnorm(50))

Add a new chunk by : 1) Code > Insert Chunk 2) Ctrl + Alt + I

plot(rnorm(500))

When you save the notebook, an HTML file containing the code and output will be saved alongside it. The name will have a “.nb.html.” suffix. .nb >> notebook. To preview the report 1) click ‘Preview’ 2) Ctrl + Shift + K

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.

In this preview, there is a Code dropdown menu. If you click on Download Rmd in this menu, you’ll get a reproducible file.

Publishing

The file saved is not a proper HTML yet. To do that go to Preview > Knit to HTML But this file will not contain the code.

Instead of doing all the knitting, you can Run >> Run All. That will update the notebook file.

Notebook HTML file and HTML files are different. HTML doesn’t have code.

But parameters can be added that can add code to the HTML file.

Creating a list

This is the list

  • Item 1
  • Item 2

Empty lines above & below the list. 2 spaces after * in bullet points. << This was emphasized as important in the tutorial.

Gratuitous title

Test Image 01

Test Image 01

Another way

<Test Image 01>
Better way

Insert image

Test Image 03

Test Image 03

From internet

From internet 2

<Test Image 5>

Tables

Inset table

knitr::kable(mtcars[1:5,, 1:5], caption = "A table caption")
## Warning in if (drop) {: the condition has length > 1 and only the first
## element will be used
A table caption
mpg cyl disp hp drat wt qsec vs am gear carb
Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2