vendredi 23 juin 2017

Dynamic tabpanel with contents shiny

I am trying to build a dynamic shiny app and i would like to generate tabpanel with some contents if a condition is met. I am uploading a dataset and the condition will be on the class() of each variable. Here is a small reproduction and the condition could be even/odd number ( i took this example from a question that was answerd on Stack ) Any help would be deeply appreciated.

    library(shiny)
runApp(list(
  ui = pageWithSidebar(
    headerPanel('Dynamic Tabs'),
    sidebarPanel(
      numericInput("nTabs", 'No. of Tabs', 5)
    ),
    mainPanel(
      uiOutput('mytabs')  
    )
  ),
  server = function(input, output, session){
    output$mytabs = renderUI({
      nTabs = input$nTabs
      myTabs = lapply(paste('Tab', 1: nTabs), tabPanel)
      do.call(tabsetPanel, myTabs)
    })
  }
))

Aucun commentaire:

Enregistrer un commentaire