Search code examples
rflexdashboard

r flex dashboard layout with tabs and panels


I am interested in a flexboard layout with two tabs and within each tab the layout be split into three tiles or panels.

This will give me a layout with three panels which is good.

---
title: "Panels"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

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

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}
```

Column {data-width=350}
-----------------------------------------------------------------------

### Chart B

```{r}
```

### Chart C

```{r}
```

This will give me a layout with two tabs

---
title: "Tabs"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

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

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

### Sheet 1

```{r}
```   

### Sheet 2

```{r}
```

How can I put these two together so that my layout looks like this below

enter image description here


Solution

  • You need to add this under your YAML header in the first example you provided:

    Sheet1
    ===
    

    The === will append tabs to your dashboard.

    So it would look like:

    ---
    title: "Panels"
    output: 
      flexdashboard::flex_dashboard:
        orientation: columns
        vertical_layout: fill
    ---
    Sheet1
    ===
    
    ```{r setup, include=FALSE}
    library(flexdashboard)
    ```
    
    Column {data-width=650}
    -----------------------------------------------------------------------
    
    ### Chart A
    
    ```{r}
    ```
    
    Column {data-width=350}
    -----------------------------------------------------------------------
    
    ### Chart B
    
    ```{r}
    ```
    
    ### Chart C
    
    ```{r}
    ```
    
    Sheet2
    ===
    

    etc...