0

Let's say I have this output output 1

As you can see, R markdown breaks the results into 4 sections. I would like to print these results into 4 tabs, similar as the image below:

enter image description here

I've looked before at this thread, but I did not find any solution. Thank you

Full code below:

ds <- data.frame(x1=rbinom(100, 1,0.5),x2=rbinom(100, 1,0.5),x3=rbinom(100, 1,0.5))
psych::alpha(ds)
Luis
  • 1,388
  • 10
  • 30

1 Answers1

0

Conceptually, you are there already. Just think about how you want to split / spread your output over the tabsets you plan.

I revert back to the iris data set, as I did not want to install the {psych} package. But from the image you get dataframes.
I simulate different data frames by subsetting iris, e.g. think df1 <- iris[1:10,].

You can place the different objects (data frames), visualisations/plots, or text in a standard Rmd way inside the tabset part.

---
title: "Tabed output"
author: "Demo-Author"
date: "28/07/2021"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)

library(magrittr)  # for using the pipe

df <- iris
```

## title {.tabset .tabset-fade}

This is content above tabbed region.    

The next level heading will start the tabset where you can place the content

### tab 1 

tab content 1 commentary

```{r}
df[1:10,] %>% knitr::kable()
```


### tab 2

tab content 2 commentary above a table.

```{r}
df[11:25,] %>% knitr::kable()
```

##

content below tabbed region and your further Rmd story!

... will give you the following output (I stick to 2 tabs), but you will get the principle.

tabset content example

Ray
  • 2,008
  • 14
  • 21