flexdashboard tabset with tables

Viewed 406

When I add a table by DT::datatable or KableExtra::kbl() in a column with {.tabset} the output is not rendered in flexdashboard.

Any idea how to get a proper result?

Example:

I want to have one column with tabs. This is working without adding a table in the output component like in the example below

---
title: "tabs working"
output:
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: scroll
---

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

Page
=================================

Column {.tabset}
---------------------------------

### Tab 1 
```{r }

```

### Tab 2
```{r}

```

When I do the same with datatable objects it is not rendered properly.

---
title: "tabs not working"
output:
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: scroll
---

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

```{r load packages, echo=FALSE, include=FALSE}

library(DT)

```


Page
=================================

Column {.tabset}
---------------------------------

### Tab 1 
```{r }
datatable(data.frame(seq(5, 3)))
```

### Tab 2
```{r}
datatable(data.frame(seq(5, 3)))
```

Then the output is like this

1 Answers

If you add a second column it will render.

---
title: "tabs not working"
output:
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: scroll
---

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

```{r load packages, echo=FALSE, include=FALSE}
library(flexdashboard)
library(DT)
library(tidyverse)

```

Page
=================================

Column {.tabset}
---------------------------------

### Tab 1 
```{r }
datatable(data.frame(seq(5,3)),
          fillContainer = FALSE)
```

### Tab 2
```{r}
datatable(data.frame(seq(5,3)),
          fillContainer = FALSE)
```

Column 
---------------------------------
### Column 1
```{r, echo = FALSE}
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + 
  geom_point()
```

In the alternative, if you only want one column that includes the tabset, it's the equivalent of a single row. If you switch the layout to rows, it will render on its own. If you want to add columns further down the flexdashboard, you can just specify Column in the second block below.

---
title: "Untitled"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
---

```{r setup, include=FALSE}
library(flexdashboard)
library(DT)
library(tidyverse)
```


Page
=================================

Row {.tabset}
---------------------------------

### Tab 1
    ```{r }
iris %>% 
  datatable()
```

### Tab 2
```{r}
mtcars %>% 
  datatable()
```

Column
---------------------------------
### Column 1
```{r, echo = FALSE}
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + 
  geom_point()
```

### Column 2
```{r, echo = FALSE}
ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + 
  geom_point()
```
Related