Skip to content

Instantly share code, notes, and snippets.

@SemiQuant
Created May 10, 2019 08:38
Show Gist options
  • Save SemiQuant/9f010b330122f79861bbb63ad2ea3d30 to your computer and use it in GitHub Desktop.
Save SemiQuant/9f010b330122f79861bbb63ad2ea3d30 to your computer and use it in GitHub Desktop.
Tab box in a flex dashboard with tabbed columns
---
title: "Tabbed Tabs"
author: "SemiQuant"
date: "5/10/2019"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
---
```{r setup, include=FALSE}
require(flexdashboard)
```
Column {.tabset}
-------------------------------------
### Tab 1
```{r echo=FALSE}
require(shinydashboard)
require(shiny)
require(plotly)
p1 <- plot_ly(midwest, x = ~percollege, color = ~state, type = "box")
p2 <- plot_ly(midwest, x = ~percollege, type = "box", width = 600, height = 400)
# if you do not set the dimensions on the plot in the second tab it becomes distorted
tabBox(width=12,
title = "First tabBox",
id = "tabset1",
tabPanel("TabA", p1),
tabPanel("TabB", p2)
)
```
-------------------------------------
### Tab 2
```{r}
require(plotly)
plot_ly(midwest, x = ~percollege, color = ~state, type = "box")
```
@DGG79
Copy link

DGG79 commented Apr 20, 2021

Thank you SemiQuant! This workaround is indeed very helpful.

I am trying to display in this way:
(1) tables created with kableExtra::kable()
(2) graphs created with dygraphs::dygraph()

So far I have managed to do (1), transforming first the original table vía htmltools::HTML() (see code below). However, I am not able to do something similar with dygraph graphs (I got an Error in FUNC(X[[i]], ...): argument is not a character cector cCalls: >Anonymous> .... that I cannot make sense of).

I am quite new to R, flexdashboard and HTML code, and I do not have a good understanding of the objects that I am dealing with, which migtht explain why I am struggling with this. Can anyone help me?

Displaying a KABLE in nested tabs - It works

Row {.tabset}

Kable table

require(shinydashboard)
require(shiny)
require(htmltools)

shinydashboard::tabBox(width='100%', height='100%',
      title = "",
      id = "TabsetName",
      shiny::tabPanel("Tab1", htmltools::HTML(table1)),
      shiny::tabPanel("Tab2", htmltools::HTML(table2)),
    )

Displaying a DYGRAPH in nested tabs - It does not work

Row {.tabset}

Kable table

require(shinydashboard)
require(shiny)
require(htmltools)

shinydashboard::tabBox(width='100%', height='100%',
      title = "",
      id = "TabsetName",
      shiny::tabPanel("Tab1", htmltools::HTML(dygraph1)),
      shiny::tabPanel("Tab2", htmltools::HTML(dygraph1)),
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment