8 Lesson 3: Basic Syntax

8.1 Heading Text

Heading text follows one or more hash-sign(s) (#). The number of hash-signs determines the hierarchy of headings. For example, “# Heading 1” would represent the primary heading, “## Heading 2” would represent the secondary heading, “### Heading 3” would represent the tertiary heading, and so forth.

8.2 Plain Text

Simply add text below the YAML header. To start a new paragraph, you will need to end your plain text line with two (2) spaces.

8.3 Bold and Italicized Text

There are two ways to format your text to be bold or italicized.

  • Bold
    • Surround your text with two (2) asterisks (*) on each side.
    • Surround your text with two (2) underscores (_) on each side.
  • Italicized
    • Surround your text with one (1) asterisk (*) on each side.
    • Surround your text with one (1) underscore (_) on each side.

The markdown syntax…

which renders to…

Bold Text Example

Bold Text Example

Italicize Text Example

Italicize Text Example

8.4 Lists

8.4.1 Unordered Lists

Unordered or bulleted lists can be generated by using a single asterisk (*) followed by a space and the plain text intended to represent the bullet. To add another bullet, just hit enter or return and follow the previous steps. To add sub-bullets, insert two spaces and a plus sign (+) followed by a space and the plain text intended to represent the sub-bullet. You can do this at multiple levels; meaning you can add four spaces and a plus sign (+) to insert a sub-sub-bullet and six spaces and a plus sign (+) to add a sub-sub-sub-bullet.

The markdown syntax…

which renders to…

  • Bullet 1
  • Bullet 2
    • Sub-Bullet 1
    • Sub-Bullet 2
      • Sub-Sub-Bullet 1
      • Sub-Sub-Bullet 2

8.4.2 Ordered Lists

Follow the steps in Unordered Lists but instead of using asterisk (*) use sequential numbers followed by a period (.)– this cannot be done for sub-bullets. For example, “1.”, “2.”, and “3.”.

The markdown syntax…

which renders to…

  1. Bullet 1
    • Sub-Bullet 1
  2. Bullet 2
    • Sub-Bullet 1
    • Sub-Bullet 2
      • Sub-Sub-Bullet 1

8.7 Insert Images

You can insert images into your document using syntax similar to the hyperlink syntax above.

In the code below you can see the file path the to the image. This image will render without a caption

![](images/hex_symbols/rmarkdown.png)

You can add a caption for the image in between the square brackets.

![This is my caption for the image.](images/hex_symbols/rmarkdown.png)

This is my caption for the image.

This is my caption for the image.

You can control the size of the image like this…

![This is my caption for the image.](images/hex_symbols/rmarkdown.png){width=200px}

This is my caption for the image.

This is my caption for the image.

You can center the image with HTML like this…

This is my caption for the image.

8.8 Tabbed Sections

Tabbed sections can be added to section of an HTML documents that will fold all of the subsequent sub-sections into separate tabs. To do this you specify a section header followed by {.tabset}. For example, ## My Section Header {.tabset}.

Note this feature is not available for use with bookdown.

8.9 Your Turn

  1. Using the .Rmd file created in Lesson 2: Rmd Creation, delete everything below the YAML header.
  2. Add the following level-1 headers and knit the document.
    • Introduction
    • Workflow
    • Import Data
    • Preprocessing
    • Study Area
    • Plot
    • Conclusions
  3. Add two level-2 headers below the Plot header and knit the document.
    • Scatter Plot
    • LOESS Plot
  4. Add plain text below the Introduction header and knit the document.
    • Be sure to include some bold and italicized text.
    • Explain the purpose of the document (e.g., “This document was created during the 2020 NABs R Markdown workshop and will serve as an example workflow for my future use of R Markdown.”)
    • Include the hyperlink to R Markdown: The Definitive Guide (https://bookdown.org/yihui/rmarkdown/). This will be a helpful resource in the future.
  5. Add unordered or ordered list below the Workflow header and knit the document.
    • Describe the workflow we have talked about thus far (e.g., create an R project, add folders, create an rmarkdown document, knit the document to render).
    • Add sub-bullets with helpful details.
  6. Add the image provided with the data to the Introduction.
  7. Make the Plot section tabbed section with {.tabset}.