0
votes

I need to add tabPanel to tabsetPanel dynamicaly. I also have a few constant tabPanel in the same tabsetPanel. I found only one solution (R Shiny - add tabPanel to tabsetPanel dynamically (with the use of renderUI))

And I built my code with respect to this article. But now I could not call these tabPanels and print any information over there.

Can somebody advice me how to call my tabPanels or how to organize the dynamical usage/adding of the tabPanels, please

library(shiny)


shinyUI(fluidPage(
  title = 'Examples of DataTables',
  sidebarLayout(

    sidebarPanel(
      wellPanel(
        numericInput('crlevel', "Q-ty of criterion levels",2)
      ),
            textOutput("text1"),
           conditionalPanel(
        "input.tabPanel === 'Tab 2'",
      helpText('helptext - Test1'),
      numericInput ("level","Test2. Q-ty of Criterion levels:", 3)
        )  
    ),

    mainPanel(
      uiOutput("mytabs")
    )
  )
))




library(shiny)

 shinyServer(function(input, output,session) {

output$text1 <- renderText({
    paste("The value of input$crlevel is: ", input$crlevel
    )
  })
  output$mytabs <- renderUI({
      do.call(tabsetPanel, lapply(1:(input$crlevel+2), function(x){      
      if (x == 1) {tabPanel("options", textOutput("options"))
      }else {
      tabPanel(paste('Tab', x), uiOutput('Tab', x))
      }
    })
    )
  })  
output$options <- renderText({
  paste("Hello world! "
  )
})
})
1

1 Answers

2
votes

I found mistake, if somebody interested. It was pretty much simple:

WRONG tabPanel(paste('Tab', x), uiOutput('Tab', x))

RIGHT tabPanel(paste('Tab', x), uiOutput(paste('Tab', x)))

:-D