---
title: 'RMarkdown Header'
subtitle: 'Template for RMarkdown files.'
author: 'Amir Freund'
date: '`r Sys.Date()`'
output:
  html_document:
    code_folding: hide # show / hide
    toc: true # table of content true
    toc_depth: 3  # upto three depths of headings (specified by #, ## and ###)
    toc_float: # Allows the TOC to float on the page.
      collapsed: false # Ensures the TOC is expanded by default and not collapsible.
    theme: flatly
    highlight: tango
    number_sections: true  ## if you want number sections at each table header
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(
  fig.width = 10,
  fig.height = 7,
  echo = TRUE,
  warning = FALSE,
  message = FALSE,
  collapse = TRUE,
  comment = ''
)
```

1 Understanding the Header

This document explains each component of the R Markdown header configuration and its purpose.

1.1 YAML Header Section

The header begins with three dashes (---) and contains YAML (YAML Ain’t Markup Language) metadata that controls the document’s appearance and behavior.

1.1.1 Basic Document Information

title: "Descriptive Statistics"
author: "Amir Freund"
date: "2025-02-05"
  • title: Sets the document’s main title
  • author: Specifies the document’s author
  • date: Uses R code (2025-02-05) to automatically insert the current date

1.1.2 Output Configuration

output: 
  html_document:

Specifies that the document will be rendered as HTML with the following settings:

1.1.2.1 Document Features

    code_folding: hide
  • Controls visibility of R code chunks
  • hide: Code is hidden by default but can be expanded
  • Alternative options: show (always visible) or none (always hidden)

1.1.2.2 Table of Contents Settings

    toc: true
    toc_depth: 3
    toc_float:
      collapsed: false
  • toc: true: Enables table of contents
  • toc_depth: 3: Includes headings up to three levels deep (# to ###)
  • toc_float: Makes the table of contents float alongside the content
    • collapsed: false: TOC is fully expanded by default

1.1.2.3 Appearance Settings

    theme: flatly
    highlight: tango
    number_sections: true
  • theme: flatly: Uses the “flatly” Bootstrap theme
  • highlight: tango: Applies the “tango” syntax highlighting style
  • number_sections: true: Automatically numbers document sections

1.2 R Setup Chunk

knitr::opts_chunk$set(
  fig.width = 10,
  fig.height = 7,
  echo = TRUE, 
  warning = FALSE,
  message = FALSE,
  collapse = TRUE,
  comment = ""
)

This R code chunk sets global options for all subsequent code chunks:

1.2.1 Figure Settings

  • fig.width = 10: Sets default figure width to 10 inches
  • fig.height = 7: Sets default figure height to 7 inches

1.2.2 Code Display Settings

  • echo = TRUE: Shows R code along with its output
  • warning = FALSE: Suppresses warning messages
  • message = FALSE: Suppresses informational messages
  • collapse = TRUE: Combines code and output into a single block
  • comment = "": Do not prefix output lines with “”