Skip to content

RMarkdown Tabset

Contents

Source: 7.6 Put content in tabs | R Markdown Cookbook (bookdown.org)

Overview

One natural way of organizing parallel sections in an HTML report is to use tabsets. This allows readers to view the content of different sections by clicking the tab titles instead of scrolling back and forth on the page.

To turn sections into tabs, you can add a class attributeĀ .tabsetĀ to the section header that is one level higher than the headers to be converted to tabs, e.g., adding theĀ .tabsetĀ attribute to a level-2 header will convert all subsequent level-3 headers to tabs. Below is a full example.

Code

To create an HTML Tabset in RMarkdown (.Rmd) - use the following syntax:

---
title: Use tabs to organize content
output: html_document
---

You can turn parallel sections to tabs in `html_document` output.

## Results {.tabset}

### Plots

We show a scatter plot in this section.

```{r, fig.dim=c(5, 3)}
par(mar = c(4, 4, .5, .1))
plot(mpg ~ hp, data = mtcars, pch = 19)
```

### Tables

We show the data in this tab.

```{r}
head(mtcars)
```

Example

Pasted image 20220918212253.png


Backlinks:


Dataview:

list from [[RMarkdown Tabset]] AND -"Changelog"