YAML Header

The YAML header appears at the top of the document within two sets of three hyphens (---). It contains metadata that can be modified, such as the title, author, date, and output options. In this example, we set the title to “My R Markdown Example,” the author to “John Doe,” and specify that the output should be an HTML document with a table of contents (toc: true).

Markdown Text

Below the YAML header, you can start writing your text using Markdown syntax. Markdown allows you to format your text easily. For example, you can create headings using hash symbols, like # Heading 1 for the main heading and ## Heading 2 for subheadings. You can also create lists, links, images, and more using Markdown formatting.

Heading 2

Here is an example of an unordered list:

  • Item 1
  • Item 2
  • Item 3

And a link: OpenAI

Image

Code Chunks

Code chunks in R Markdown are enclosed by three backticks (```). You can write your R code within these chunks. To execute a code chunk, you can use the “Run” button within the chunk or press Ctrl + Enter (or Cmd + Enter on a Mac).

Here’s an example of a code chunk that calculates the sum of two numbers:

# Adding two numbers
num1 <- 5
num2 <- 10
sum <- num1 + num2
sum
## [1] 15