Reader small image

You're reading from  The Statistics and Machine Learning with R Workshop

Product typeBook
Published inOct 2023
Reading LevelIntermediate
PublisherPackt
ISBN-139781803240305
Edition1st Edition
Languages
Right arrow
Author (1)
Liu Peng
Liu Peng
author image
Liu Peng

Peng Liu is an Assistant Professor of Quantitative Finance (Practice) at Singapore Management University and an adjunct researcher at the National University of Singapore. He holds a Ph.D. in statistics from the National University of Singapore and has ten years of working experience as a data scientist across the banking, technology, and hospitality industries.
Read more about Liu Peng

Right arrow

Customizing R Markdown reports

In this section, we will look at adding metadata such as a table of contents to the report, followed by introducing more options for changing the report style.

Adding a table of contents

When reading a report for the first time, a table of contents provides an overview of the report and thus helps readers quickly navigate the different sections of the report.

To add a table of contents, we can append a colon to the html_document field in the YAML header and set toc: true as a separate line with one more indentation than the html_document field. This is shown in the following code snippet:

---
title: "Financial analysis"
output:
    html_document:
        toc: true
date: "2022-10-12"
author: "Liu Peng"
---

Knitting the document with these commands produces Figure 6.29, where a table of contents is now displayed at the top of the report. Note that when...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
The Statistics and Machine Learning with R Workshop
Published in: Oct 2023Publisher: PacktISBN-13: 9781803240305

Author (1)

author image
Liu Peng

Peng Liu is an Assistant Professor of Quantitative Finance (Practice) at Singapore Management University and an adjunct researcher at the National University of Singapore. He holds a Ph.D. in statistics from the National University of Singapore and has ten years of working experience as a data scientist across the banking, technology, and hospitality industries.
Read more about Liu Peng